edwindj / whisker

{{mustache}} for R
https://mustache.github.io
213 stars 19 forks source link

Inconsistent treatment of newlines? #12

Closed danhalligan closed 10 years ago

danhalligan commented 10 years ago

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".

edwindj commented 10 years ago

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

edwindj commented 10 years ago

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.

danhalligan commented 10 years ago

OK great - thanks for investigating.

edwindj commented 10 years ago

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

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

Best,

Edwin

danhalligan commented 10 years ago

Looks good so far - thanks!