englue() creates a string with the glue operators { and {{. These operators are normally used to inject names within dynamic dots. englue() makes them available anywhere within a function.

englue() must be used inside a function. englue("{{ var }}") defuses the argument var and transforms it to a string using the default name operation.

englue(x)

Arguments

x

A string to interpolate with glue operators.

Details

englue("{{ var }}") is equivalent to as_label(enquo(var)). It defuses arg and transforms the expression to a string with as_label().

In dynamic dots, using only { is allowed. In englue() you must use {{ at least once. Use glue::glue() for simple interpolation.

Before using englue() in a package, first ensure that glue is installed by adding it to your Imports: section.

usethis::use_package("glue", "Imports")

Examples

g <- function(var) englue("{{ var }}")
g(cyl)
#> [1] "cyl"
g(1 + 1)
#> [1] "1 + 1"
g(!!letters)
#> [1] "<chr>"

# These are equivalent to
as_label(quote(cyl))
#> [1] "cyl"
as_label(quote(1 + 1))
#> [1] "1 + 1"
as_label(letters)
#> [1] "<chr>"