edwindj / whisker

{{mustache}} for R

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

templates don't recognise names containing `.`

mnel opened this issue · comments

Templates don' t handle names containing .

a.test <- 'World'
template <- template <- "Hello {{a.test}}!"
whisker.render(template)
## Error in value[[key]] : subscript out of bounds
whisker.render(template, list(a.test = a.test))
## [1] "Hello !"

Thanks for reporting, but it is a difficult one:

It is a kind of conflict between R and mustache/whisker.
In the mustache definition, which whisker adheres to a "." signifies a nested object (while in R a ".' is just a character of a variable name).

So strictly speaking your template usage does not conform to the mustache definition.

Whisker currently sticks to the mustache definition

a <- list(test= "Mustache World")  # ( == a$test)
a.test <-  "R World"

template <- "Hello {{a.test}}!"
whisker.render(template)

You can fix your rendering by either changing your template or by changing the list:

a.test <- "World"
template <- "Hello {{a.test}}!"
whisker.render(template, list(a = list(test=a.test)))