I would like to escape the HTML code from an imported file in Nunjucks.
{% include "item.html" %}
The file "item.html" contains following code:
<strong>bold text</strong>
I would like the parent file (which includes item.html) to have the following output:
<strong>bold text</strong>
I tried surrounding the include with an escape filter:
{% filter escape %}
{% include "item.html" %}
{% endfilter %}
However in that case the file doesn't get included correctly. Any ideas?
I tested your snippet on Gulp + gulp-nunjucks-render@2.0.0
, it does produce the desired effect:
{% filter escape %}
{% include "partials/test.html" %}
{% endfilter %}