Applying jinja2 filters to a block?

Question:

Is it possible to apply jinja2 filters to {% block ... %} constructs? What I was hoping to do was something along the lines of:

{% block content|upper %}
here is some content that will be rendered in upper case
{% endblock %}

…but this doesn’t work; the above example will result in an error. Is there any other way to wrap a chunk of template text in a jinja2 filter?

Asked By: larsks

||

Answers:

You can use filter sections:

{% block content %}
    {% filter upper %}
        Here is some content that will be rendered in upper case.
    {% endfilter %}
{% endblock %}
Answered By: Eugene Naydenov
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.