You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can parse a template, but there is no corresponding function for rendering and/or compiling the parsed template. It would be nice to have compile skip parsing if the template argument is an array (presumably of tokens).
The text was updated successfully, but these errors were encountered:
Feels a little silly that compiling tokens still requires the original template. Unfortunately, the tokens don't contain enough information to avoid this, so this is not a minor change.
For now, it appears that it does not require the template if you don't render with functions in the data, so its enough for my uses.
Yes, I agree. This is because the parsing function is destructive, atm. The most common example of this is when "unintended" whitespace is stripped from tokens. For example, when compiling the following template:
{{#foo}}
<li>A {{name}}.</li>
{{/foo}}
We strip the trailing \n character after the {{#foo}} tag. This makes it easy for users to get the output they expect without putting things on separate lines. Thus, if at render time we discover that foo is actually a higher order function we have no way of getting back the original text that was used in that section.
To work around this problem we pass the original template all the way through to the compiled rendering function so that it can slice on that string if it needs to get the original text between the bounds that indicate the beginning/end of that section. But I realize this is a bit messy, and I'm totally open to a better solution here. :)
I can
parse
a template, but there is no corresponding function for rendering and/or compiling the parsed template. It would be nice to have compile skip parsing if thetemplate
argument is an array (presumably of tokens).The text was updated successfully, but these errors were encountered: