gadenbuie / epoxy

Extra-strength glue engines for R Markdown, Quarto, and Shiny

Home Page:https://pkg.garrickadenbuie.com/epoxy/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Assignment in expressions

gadenbuie opened this issue · comments

This might be a glue thing, but assigning to a variable in the global environment works except when the value comes from the glue environment.

When the variable exists in the global env and the value is inlined:

x <- 0
null <- epoxy("{x <- 99}")
x
#> [1] 99

null <- epoxy_html("{{ x <- 404 }}")
x
#> [1] 404

null <- epoxy_latex("<< x <- 'knuth' >>", .open = "<<", .close = ">>")
x
#> [1] "knuth"

but when the value comes from the glue calling args:

x <- 0
null <- epoxy("{x <- v}", v = 99)
x
#> [1] 0

null <- epoxy_html("{{ x <- v }}", v = 404)
x
#> [1] 0

null <- epoxy_latex("<< x <- v >>", v = "knuth", .open = "<<", .close = ">>")
x
#> [1] 0

This happens in glue, too.

x <- 0
null <- glue::glue("{x <- v}", v = 99)
x
#> [1] 0