@@ -1086,35 +1086,34 @@ Assignments use the `set` tag and can have multiple targets::
1086
1086
Block Assignments
1087
1087
~~~~~~~~~~~~~~~~~
1088
1088
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 (``""" ``, ``''' ``).
1090
1092
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. It can also be used to create
1094
- multiline strings instead of triple quotes (''' and """), which Jinja does not
1095
- support. In that case, instead of using an equals sign and a value, you just
1096
- write the variable name and then 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.
1097
1095
1098
- Example::
1096
+ .. code-block :: jinja
1099
1097
1100
1098
{% set navigation %}
1101
1099
<li><a href="/">Index</a>
1102
1100
<li><a href="/downloads">Downloads</a>
1103
1101
{% endset %}
1104
1102
1105
- The `navigation ` variable then contains the navigation HTML source.
1106
-
1107
- .. versionchanged :: 2.10
1108
-
1109
- 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.
1110
1104
1111
- Example::
1105
+ .. code-block :: jinja
1112
1106
1113
1107
{% set reply | wordwrap %}
1114
1108
You wrote:
1115
1109
{{ message }}
1116
1110
{% endset %}
1117
1111
1112
+ .. versionadded :: 2.8
1113
+
1114
+ .. versionchanged :: 2.10
1115
+
1116
+ Block assignment supports filters.
1118
1117
1119
1118
.. _extends :
1120
1119
0 commit comments