edwindj / whisker

{{mustache}} for R
https://mustache.github.io
213 stars 19 forks source link

Variables with a period in the name fail #18

Open AndrewHannigan opened 10 years ago

AndrewHannigan commented 10 years ago

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!

edwindj commented 10 years ago

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" notifications@github.com:

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.

AndrewHannigan commented 10 years ago

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

kendonB commented 7 years ago

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"