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

For filters, if the input is SafeString, the output should also be SafeString #1453

Closed wenfw closed 7 months ago

wenfw commented 8 months ago

e.g.

The code below returns a SafeString.

{{ some_html_string | filter_returns_safe_string }}

Then the code below should return a SafeString too, but it does not.

{{ some_html_string | filter_returns_safe_string | upper }}
wenfw commented 7 months ago

Just discovered that we can use this approach:

{{ some_html_string | filter_returns_safe_string | upper | safe }}

I'm going to close this issue. Thanks.