File tree 1 file changed +13
-13
lines changed
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::
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. 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.
1096
1095
1097
- Example::
1096
+ .. code-block :: jinja
1098
1097
1099
1098
{% set navigation %}
1100
1099
<li><a href="/">Index</a>
1101
1100
<li><a href="/downloads">Downloads</a>
1102
1101
{% endset %}
1103
1102
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.
1109
1104
1110
- Example::
1105
+ .. code-block :: jinja
1111
1106
1112
1107
{% set reply | wordwrap %}
1113
1108
You wrote:
1114
1109
{{ message }}
1115
1110
{% endset %}
1116
1111
1112
+ .. versionadded :: 2.8
1113
+
1114
+ .. versionchanged :: 2.10
1115
+
1116
+ Block assignment supports filters.
1117
1117
1118
1118
.. _extends :
1119
1119
You can’t perform that action at this time.
0 commit comments