Skip to content
Myr

Documented {% set %}...{% endset %}

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 9bf94b5 · Browse files · 1 file+21 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+21 added−0 removed

  • other:+21 added−0 removed

1 file+21 added−0 removed

modified:docs/templates.rst+21 added
807 unmodified lines
808 {% set navigation = [('index.html', 'Index'), ('about.html', 'About')] %}809 {% set key, value = call_something() %}810811812Block Assignments813~~~~~~~~~~~~~~~~~814815.. versionadded:: 2.8816817Starting with Jinja 2.8 it's possible to also use block assignments to818capture the contents of a block into a variable name. This can be useful819in some situations as an alternative for macros. In that case instead of820using an equals sign and a value you just write the variable name and then821everything until ``{% endset %}`` is captured.822823Example::824825 {% set navigation %}826 <li><a href="/">Index</a>827 <li><a href="/downloads">Downloads</a>828 {% endset %}829830The `navigation` variable then contains the navigation HTML source.831832833Extends834~~~~~~~835836The `extends` tag can be used to extend a template from another one. You
620 unmodified lines