Skip to content

Partial indentation does not work as described #614

Closed

Description

@chandlerkent

Describe the bug

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

From the README:

string source =
@"<h2>Names</h2>
{{#names}}
  {{> user}}
{{/names}}";

string partialSource =
@"<strong>{{name}}</strong>";

Handlebars.RegisterTemplate("user", partialSource);

var template = Handlebars.Compile(source);

var data = new {
  names = new [] {
    new {
        name = "Karen"
    },
    new {
        name = "Jon"
    }
  }
};

var result = 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

  1. chandlerkent commented on Jun 11, 2026

    @chandlerkent
    Author

    I would be happy to work on a Pull Request to resolve this if this would be of interest to the project.

    Thanks for taking a look!

  2. rexm commented on Jun 11, 2026

    @rexm
    Member

    Go for it

  3. added 3 commits that reference this issue on Jun 20, 2026
  4. chandlerkent commented on Jun 23, 2026

    @chandlerkent
    Author

    @rexm thanks for getting to this!

    When do you expect to publish a new version?

  5. rexm commented on Jun 23, 2026

    @rexm
    Member

    Probably Thursday

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