Closed derekbsnider closed 2 years ago
Prepending <=%% %%=>
to the template would achieve the same result, wouldn't it?
Prepending
<=%% %%=>
to the template would achieve the same result, wouldn't it?
Yes, it would, but requires manipulating the template, which seems less clean than having access to a method to set it.
Is it "clean" to describe a template without specifying a delimiter used in it, in the first place? I understand there might be a common convention you might want to apply across a class of templates (I do have exactly that case) but I prefer to prepend the template with the intended delimiters as soon as possible to make it complete.
I personally wouldn't consider it "clean" for the only control over the template class to be via the template data itself. Many template delimiter conventions predate the Mustache convention of curly braces, and thus it would be nice to be able to specify a different default set without manipulating the input data.
Well, Mustache is not just double curly braces, the list of conventions is much longer... Even after redefining the delimiter the template language remains Mustache. But I remembered that there's already set_custom_escape()
anyway that also changes language metadata, and delimiter assignment falls in that category as well.
How would one change the delimiter using set_custom_escape()
?
One cannot; set_custom_escape()
is for a different thing.
Also have a case where being able to set the default delimiter outside of the template would be more important -- if you need to apply the template line by line, and do not have access to the whole document (i.e. inside of a stream filter).
Seems low use demand currently. Feel free to submit a PR with a test, and I'll consider it.
I think it would be particularly useful if there was a way to set what the tag delimiters were on the mustache object directly.
Example: