whisker icon indicating copy to clipboard operation
whisker copied to clipboard

Variables with a period in the name fail

Open AndrewHannigan opened this issue 9 years ago • 3 comments

Whisker seems to fail when there is a period in the name of the variable. Considering that R variables quite typically have periods in the name, this is problematic.

> whisker.render("{{user.name}}", list(user.name=342))
[1] ""
> whisker.render("{{username}}", list(username=342))
[1] "342"

If there is a way around this please let me know. I imagine it's a quick fix. Also if this is an intentional design choice that'd be good to know too. Thanks!

AndrewHannigan avatar Jul 16 '14 14:07 AndrewHannigan

Dear Andrew,

Responding from a hiking holiday with low internet access: in the latest version on github it is possible to switch from "." to "$" as separation symbol. The "." is the default so whisker conforms to the mustache standard.

Best regards,

Edwin Op 16 jul. 2014 16:32 schreef "Andrew Hannigan" [email protected]:

Whisker seems to fail when there is a period in the name of the variable. Considering that R variables quite typically have periods in the name, this is very problematic.

whisker.render("{{user.name}}", list(user.name=342)) [1] "" whisker.render("{{username}}", list(username=342)) [1] "342"

If there is a way around this please let me know. Also, if this is an intentional design decision, it would be good to hear the reason for doing so.

— Reply to this email directly or view it on GitHub https://github.com/edwindj/whisker/issues/18.

edwindj avatar Jul 20 '14 11:07 edwindj

Hi Edwin - thanks for the update, I'll check that out. Enjoy the views!

AndrewHannigan avatar Jul 21 '14 20:07 AndrewHannigan

I feel like it makes sense to use $ by default for the separation symbol. . is all ubiquitous in R object names. For example, make.names uses "." as the replacement when it sees a symbol it doesn't like:

make.names("var$name")
#> [1] "var.name"

kendonB avatar Apr 18 '17 17:04 kendonB