From: Armin Ronacher Date: Fri, 6 Jun 2014 18:58:38 +0000 (+0600) Subject: Documented {% set %}...{% endset %} X-Git-Tag: 2.8~59 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d91ae5fff0cde03e09f430bcf7a314e1c09895a;p=thirdparty%2Fjinja.git Documented {% set %}...{% endset %} --- diff --git a/docs/templates.rst b/docs/templates.rst index cd947ca7..20dacfd8 100644 --- a/docs/templates.rst +++ b/docs/templates.rst @@ -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 %} +
  • Index +
  • Downloads + {% endset %} + +The `navigation` variable then contains the navigation HTML source. + + Extends ~~~~~~~