mozilla / nunjucks

A powerful templating engine with inheritance, asynchronous control, and more (jinja2 inspired)
https://mozilla.github.io/nunjucks/
BSD 2-Clause "Simplified" License
8.48k stars 634 forks source link

Indent inside filter tag indents the line after the `endfilter` when `trimBlocks` is true #1447

Open viennem opened 10 months ago

viennem commented 10 months ago

When trimBlocks is true, and I use the indent filter inside a filter tag, like this:

{% filter indent(4, true) %}
myLine1
myLine2
{% endfilter %}
myLine3

then the line after the endfilter tag is also indented, and I get this output:

    myLine1
    myLine2
    myLine3

I was expecting this output instead:

    myLine1
    myLine2
myLine3

I am using nunjucks 3.2.4.

viennem commented 10 months ago

Workarounds:

  1. Change the template like this:

    {% filter indent(4, true) %}
    myLine1
    myLine2
    {%- endfilter %}
    
    myLine3
  2. Or set trimBlocks to false.

viennem commented 10 months ago

I confirmed that I get the expected output when using jinja instead of nunjucks.