Indentation When Partial Expands to Template Variable
I need to be able to template content while preserving indentation across multiple lines. (We use templating to insert student code submission into a wrapper, so indentation is important to preserve for legibility and linting.)
The following approach (taken from StackOverflow) works with handlebars.js:
- Register a partial that expands to
{{{ contents }}}. Call itContent. - Then use
{{>Content }}in lieu of{{{ contents }}}in the input.
However, the same approach in handlebars.java does not work. Indentation is only preserved on the first line, both with and without prettyprint(true).
I don't know if the handlebars.js behavior conforms to the spec or not. Regardless, it would be nice to support this use case somehow. (Currently I'm adding the indentation to the input source manually, but this is brittle in the general case.)
@gchallen I ran into this issue too and wrote about it in https://github.com/jknack/handlebars.java/issues/401