larsks
larsks

Reputation: 311486

Applying jinja2 filters to a block?

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?

Upvotes: 15

Views: 2871

Answers (1)

Eugene Naydenov
Eugene Naydenov

Reputation: 7295

You can use filter sections:

{% block content %}
    {% filter upper %}
        Here is some content that will be rendered in upper case.
    {% endfilter %}
{% endblock %}

Upvotes: 14

Related Questions