Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safe version of glue #140

Closed
jimhester opened this issue Jul 16, 2019 · 5 comments
Closed

Safe version of glue #140

jimhester opened this issue Jul 16, 2019 · 5 comments
Labels
feature a feature request or enhancement

Comments

@jimhester
Copy link
Collaborator

It would be useful to have a safe version of glue that did not evaluate arguments, only looked them up with get(). This way glue could be used in shiny apps and similar places without concern. It is of course possible to do this already with a custom transformer, but it seems a common enough case we should probably have a new function for it.

@jcheng5
Copy link

jcheng5 commented Mar 13, 2020

@rich-iannone and I ended up needing something like this for a package that needs "safe glue" in a bunch of places, and discovered that .transformer = base::get actually works nicely!

However, I totally agree that a first-class glue function that works this way would be fantastic--the idea that people might be using regular glue::glue with Shiny is terrifying!

@jimhester
Copy link
Collaborator Author

jimhester commented Mar 13, 2020

I didn't realize the pos argument to get() also takes environments, so yeah .transformer = base::get seems like a solution. I also didn't see this response until after posting my reply in the other thread, apologies for telling you something you had already done!

@jimhester jimhester added the feature a feature request or enhancement label Mar 13, 2020
@jimhester
Copy link
Collaborator Author

I will add a glue_safe() function using get() in the next CRAN release of glue.

@jcheng5
Copy link

jcheng5 commented Mar 13, 2020

Along similar lines, can I also request for glue_data to treat envir = NULL like envir = emptyenv()? (Not sure what you'd want to do with glue(envir = NULL).)

Because the other "gotcha" we've had with glue for package development is intending to operate on user data (i.e. glue_data(.x = ...)) but accidentally including local/lexical scope (i.e. the variables belonging to the package).

@jimhester
Copy link
Collaborator Author

Closed by 46a3ee3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants