Skip to content
Myr

Triple quotes in docs (#2064)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by GitHub · parents e7cb37d, 8a8eafc · Browse files · 1 file+13 added−13 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+13 added−13 removed

  • other:+13 added−13 removed

1 file+13 added−13 removed

modified:docs/templates.rst+13 added-13 removed
1084 unmodified lines
10851086Block Assignments1087~~~~~~~~~~~~~~~~~10881089.. versionadded:: 2.81089It's possible to use `set` as a block to assign the content of the block to a1090variable. This can be used to create multi-line strings, since Jinja doesn't1091support Python's triple quotes (``"""``, ``'''``).10921091Starting with Jinja 2.8, it's possible to also use block assignments to1092capture the contents of a block into a variable name. This can be useful1093in some situations as an alternative for macros. In that case, instead of1094using an equals sign and a value, you just write the variable name and then1095everything until ``{% endset %}`` is captured.1093Instead of using an equals sign and a value, you only write the variable name,1094and everything until ``{% endset %}`` is captured.10951097Example::1096.. code-block:: jinja10971098 {% set navigation %}1099 <li><a href="/">Index</a>1100 <li><a href="/downloads">Downloads</a>1101 {% endset %}11021104The `navigation` variable then contains the navigation HTML source.1103Filters applied to the variable name will be applied to the block's content.11041106.. versionchanged:: 2.101105.. code-block:: jinja11061108Starting with Jinja 2.10, the block assignment supports filters.11091110Example::11111107 {% set reply | wordwrap %}1108 You wrote:1109 {{ message }}1110 {% endset %}11111112.. versionadded:: 2.811131114.. versionchanged:: 2.1011151116 Block assignment supports filters.11171118.. _extends:11191120Extends1121~~~~~~~
841 unmodified lines