edwindj / whisker

{{mustache}} for R

Home Page:https://mustache.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Variables with a period in the name fail

AndrewHannigan opened this issue · 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!

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
#18.

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

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"