Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variables that start with period are replaced with empty string #34

Open
seth127 opened this issue Feb 11, 2021 · 0 comments
Open

Variables that start with period are replaced with empty string #34

seth127 opened this issue Feb 11, 2021 · 0 comments

Comments

@seth127
Copy link

seth127 commented Feb 11, 2021

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant