edwindj / whisker

{{mustache}} for R

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inconsistent treatment of newlines?

danhalligan opened this issue · comments

I'm hoping to use whisker for a markdown file where treatment of spaces and newlines is critical for, for example, specifying new paragraphs. I think the treatment of newlines may be inconsistent when using whisker.

For example, consider this template and calls to whisker.render:

template <- 
"{{#var}}
var is true
{{/var}}
{{^var}}
var is not true
{{/var}}"
whisker.render(template, list(var=TRUE))
whisker.render(template, list(var=FALSE))

I would expect the output to be either "var is true\n" or "var is not true\n" depending on the value of var. However, in the second case, the output has an extra newline at the start: "\nvar is not true\n".

Thanks for finding that! I will look into it this weekend (bit tied up right now).

Hmm, well, the specification of mustache is rather strict:
when I fix your requested behavior, it fails in other cases of the specification: so I need some more time to find out if I can fix it: It has to do with inlining/removing "standalone" tags.

(tests can be run with devtools::test() )

Will look further into it end of this week.

OK great - thanks for investigating.

@danhalligan, could you please check if it is working for you?

Closing it for now, don't hesitate to reopen if needed :-)

Best,

Edwin

Looks good so far - thanks!