Skip to content

Indentation When Partial Expands to Template Variable #708

@gchallen

Description

@gchallen

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 it Content.
  • 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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions