handlebars.java icon indicating copy to clipboard operation
handlebars.java copied to clipboard

Whitespace trimming does not work on partial blocks

Open maxb opened this issue 1 year ago • 1 comments

Given this code (using 4.3.1):

        Handlebars handlebars = new Handlebars();
        Template template = handlebars.compile("root");
        System.out.println(template.apply(null));

and this root template:

BEGIN
{{~#>partial_test ~}}
MIDDLE
{{~/partial_test ~}}
END

and this partial_test template:

{{~> @partial-block ~}}

I expect no blank lines in the output, as whitespace is being stripped at every tag entry and exit.

However what I actually get is:

BEGIN

MIDDLE

END

It seems like the whitespace strip is not respected on any partial tags.

This is frustrating, as it means there is no way to write a filter-style partial block, which does not add extra whitespace, without starting the content immediately after the closing brace of the {{#> }} tag.

maxb avatar Jul 27 '23 10:07 maxb

I've edited the originally submitted reproduction recipe, replacing with a simpler one, which also showcases an additional issue.

maxb avatar Jul 27 '23 13:07 maxb