class Crinja::Tag::Set
- Crinja::Tag::Set
- Crinja::Tag
- Reference
- Object
Overview
Inside code blocks, you can also assign values to variables. Assignments at top level (outside of blocks, macros or loops) are exported from the template like top level macros and can be imported by other templates.
Assignments use the set tag and can have multiple targets:
{% set navigation = [('index.html', 'Index'), ('about.html', 'About')] %}
{% set key, value = call_something() %}
It is also possible to use block assignments to capture the contents of a set
block into a
variable name. Instead of using an equals sign and a value, you just write the variable name and
then everything until {% endset %}
is captured.
{% set navigation %}
See [Jinja2 Template Documentation](http://jinja.pocoo.org/docs/2.9/templates/#assignments) for details.