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 filter does not ignore empty lines #1421

Open dhruvkb opened 1 year ago

dhruvkb commented 1 year ago

When using the indent filter on a block, empty lines are also indented. This is a divergence between Jinja and Nunjucks behaviour and should be addressed.

For example, the template below

{% set content %}
This is some text

and this is some more text.
{% endset %}
{% set content = content | indent(2, true) %}
{{ content }}

when rendered produces

..This is some text
..
..and this is some more text.

instead of

..This is some text

..and this is some more text.

Jinja issue: https://github.com/pallets/jinja/issues/681 Jinja PR: https://github.com/pallets/jinja/pull/685