Skip to content

Partial indentation does not work as described #614

Description

@chandlerkent

Describe the bug

Indentation of the partial invocation site is not maintained when the partial is expanded.

From the README:

stringsource=@"<h2>Names</h2>{{#names}} {{> user}}{{/names}}";stringpartialSource=@"<strong>{{name}}</strong>";Handlebars.RegisterTemplate("user",partialSource);vartemplate=Handlebars.Compile(source);vardata=new{names=new[]{new{name="Karen"},new{name="Jon"}}};varresult=template(data);/* Would render:<h2>Names</h2> <strong>Karen</strong> <strong>Jon</strong>*/

Actual result:

<h2>Names</h2>
<strong>Karen</strong><strong>Jon</strong>

Here is a Fiddle to demonstrate:

https://dotnetfiddle.net/uB3Hmu

Expected behavior:

I expect the indentation of the partial invocation site to be respected when the partial is expanded. This would match other Handlebars implementations I've used, including the "official" npm package handlebars.

You can see the expected output on the Handlebars playground:

https://handlebarsjs.com/playground.html#format=1&currentExample=%7B%22template%22%3A%22%3Ch2%3ENames%3C%2Fh2%3E%5Cn%7B%7B%23names%7D%7D%5Cn%20%20%7B%7B%3E%20user%7D%7D%5Cn%7B%7B%2Fnames%7D%7D%22%2C%22partials%22%3A%5B%7B%22name%22%3A%22user%22%2C%22content%22%3A%22%3Cstrong%3E%7B%7Bname%7D%7D%3C%2Fstrong%3E%5Cn%22%7D%5D%2C%22input%22%3A%22%7B%5Cn%20%20names%3A%20%5B%5Cn%20%20%20%20%7B%5Cn%20%20%20%20%20%20name%3A%20%5C%22Karen%5C%22%5Cn%20%20%20%20%7D%2C%5Cn%20%20%20%20%7B%5Cn%20%20%20%20%20%20name%3A%20%5C%22Jon%5C%22%5Cn%20%20%20%20%7D%5Cn%20%20%5D%5Cn%7D%5Cn%22%2C%22output%22%3A%22%3Ch2%3ENames%3C%2Fh2%3E%5Cn%20%20%3Cstrong%3EKaren%3C%2Fstrong%3E%5Cn%20%20%3Cstrong%3EJon%3C%2Fstrong%3E%5Cn%22%2C%22preparationScript%22%3A%22Handlebars.registerHelper('loud'%2C%20function%20(aString)%20%7B%5Cn%20%20return%20aString.toUpperCase()%5Cn%7D)%5Cn%22%2C%22handlebarsVersion%22%3A%224.7.9%22%7D

Screenshot:

Image

Test to reproduce

https://dotnetfiddle.net/uB3Hmu

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions