`self` variable is not defined
Author: arcanisCreated Dec 6, 2013Updated Jul 15, 2025
Labelsenhancement
Hi,
The following code triggers an error (), is it normal ? It works fine in jinja :
{% block test %}{% endblock %}
{{ self.test() }}(self.test() should return the content of the test block, especially useful when you want to wrap contents such as in the following example)
{% if self.test() | trim != "" %}
<div class="wrapper">
{% block test %}{% endblock %}
</div>
{% endif %}Source: mozilla/nunjucks