edwindj / whisker

{{mustache}} for R

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Variables that start with period are replaced with empty string

seth127 opened this issue · comments

I was using the pattern sometimes used in the tidyverse where you name your variables something short with a period at the beginning like .v1 or .v2. This doesn't work in whisker for some reason. The variable just gets replaced by an empty string.

See your example (slightly altered) below. When I change name to .name it no longer renders:

template <- 
  'Hello {{.name}}
You have just won ${{value}}!
{{#in_ca}}
Well, ${{taxed_value}}, after taxes.
{{/in_ca}}
'

data <- list( .name = "Chris"
              , value = 10000
              , taxed_value = 10000 - (10000 * 0.4)
              , in_ca = TRUE
)

text <- whisker.render(template, data)
cat(text)
## Hello 
## You have just won $10000!
## Well, $6000, after taxes.