Skip to content
Myr

Merge branch '2.9-maintenance'

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 · parents 095663c, 9574abe · Browse files · 1 file+18 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+18 added−0 removed

  • other:+18 added−0 removed

1 file+18 added−0 removed

modified:docs/templates.rst+18 added
1513 unmodified lines
1514 {% set foo = 42 %}1515 {{ foo }}1516 {% endwith %}15171518An important note on scoping here. In Jinja versions before 2.9 the1519behavior of referencing one variable to another had some unintended1520consequences. In particular one variable could refer to another defined1521in the same with block's opening statement. This caused issues with the1522cleaned up scoping behavior and has since been improved. In particular1523in newer Jinja2 versions the following code always refers to the variable1524`a` from outside the `with` block::15251526 {% with a={}, b=a.attribute %}...{% endwith %}15271528In earlier Jinja versions the `b` attribute would refer to the results of1529the first attribute. If you depend on this behavior you can rewrite it to1530use the ``set`` tag::15311532 {% with a={} %}1533 {% set b = a.attribute %}1534 {% endwith %}15351536.. admonition:: Extension15371538 In older versions of Jinja (before 2.9) it was required to enable this1539 feature with an extension. It's now enabled by default.
27 unmodified lines