File tree Expand file tree Collapse file tree 1 file changed +13
-13
lines changed
Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -1086,34 +1086,34 @@ Assignments use the `set` tag and can have multiple targets::
10861086Block Assignments
10871087~~~~~~~~~~~~~~~~~
10881088
1089- .. versionadded :: 2.8
1089+ It's possible to use `set ` as a block to assign the content of the block to a
1090+ variable. This can be used to create multi-line strings, since Jinja doesn't
1091+ support Python's triple quotes (``""" ``, ``''' ``).
10901092
1091- Starting with Jinja 2.8, it's possible to also use block assignments to
1092- capture the contents of a block into a variable name. This can be useful
1093- in some situations as an alternative for macros. In that case, instead of
1094- using an equals sign and a value, you just write the variable name and then
1095- everything until ``{% endset %} `` is captured.
1093+ Instead of using an equals sign and a value, you only write the variable name,
1094+ and everything until ``{% endset %} `` is captured.
10961095
1097- Example::
1096+ .. code-block :: jinja
10981097
10991098 {% set navigation %}
11001099 <li><a href="/">Index</a>
11011100 <li><a href="/downloads">Downloads</a>
11021101 {% endset %}
11031102
1104- The `navigation ` variable then contains the navigation HTML source.
1105-
1106- .. versionchanged :: 2.10
1107-
1108- Starting with Jinja 2.10, the block assignment supports filters.
1103+ Filters applied to the variable name will be applied to the block's content.
11091104
1110- Example::
1105+ .. code-block :: jinja
11111106
11121107 {% set reply | wordwrap %}
11131108 You wrote:
11141109 {{ message }}
11151110 {% endset %}
11161111
1112+ .. versionadded :: 2.8
1113+
1114+ .. versionchanged :: 2.10
1115+
1116+ Block assignment supports filters.
11171117
11181118.. _extends :
11191119
You can’t perform that action at this time.
0 commit comments