]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
Documented {% set %}...{% endset %}
authorArmin Ronacher <armin.ronacher@active-4.com>
Fri, 6 Jun 2014 18:58:38 +0000 (00:58 +0600)
committerArmin Ronacher <armin.ronacher@active-4.com>
Fri, 6 Jun 2014 18:58:38 +0000 (00:58 +0600)
docs/templates.rst

index cd947ca7e52cc9e3d907d19744f04cddd626d830..20dacfd8b3d76afd912cb8560f8bdfc89956f4a8 100644 (file)
@@ -809,6 +809,27 @@ Assignments use the `set` tag and can have multiple targets::
     {% set key, value = call_something() %}
 
 
+Block Assignments
+~~~~~~~~~~~~~~~~~
+
+.. versionadded:: 2.8
+
+Starting with Jinja 2.8 it's possible to also use block assignments to
+capture the contents of a block into a variable name.  This can be useful
+in some situations as an alternative for macros.  In that case instead of
+using an equals sign and a value you just write the variable name and then
+everything until ``{% endset %}`` is captured.
+
+Example::
+
+    {% set navigation %}
+        <li><a href="/">Index</a>
+        <li><a href="/downloads">Downloads</a>
+    {% endset %}
+
+The `navigation` variable then contains the navigation HTML source.
+
+
 Extends
 ~~~~~~~