noahmorrison / chevron

A Python implementation of mustache
MIT License
505 stars 55 forks source link

Indentation is not being preserved in nested partials #100

Open wichon opened 3 years ago

wichon commented 3 years ago

Indentation is not working for nested partials, nested partials are getting an extra indentation level for subsequent lines in the partial, and the lines after the partial is rendered back in the upper level template don't return to their indentation level.

For example, I am using the command line (eg. chevron -d data.json main.mustache with an empty data.json) and the following mustache template files:

# main.mustache
  \
  {{>partial1}}
  /

# partial1.mustache
|
{{>partial2}}
|

# partial2.mustache
[
{{>partial3}}
]

# partial3.mustache
<
>

And the expected output should be:

  \
  |
  [
  <
  >
  ]
  |
  /

But I am getting:

  \
  |
  [
    <
        >
]
|
  /

One level nested partials work fine. This can cause an unwanted behavior specially for indentation sensitive file formats like YAML.

sadiqkhoja commented 1 year ago

having the same problem