Add assignments documentation

This commit is contained in:
bott 2018-11-13 21:47:01 +01:00 committed by Dirkjan Ochtman
parent e7fde0733b
commit c7fe975b27

View File

@ -119,6 +119,27 @@
//! while `{{ user.name }}` will get the ``name`` field of the ``user``
//! field from the template context.
//!
//! ## Assignments
//!
//! Inside code blocks, you can also declare variables or assign values
//! to variables.
//! Assignments can't be imported by other templates.
//!
//! Assignments use the let tag:
//!
//! ```text
//! {% let name = user.name %}
//! {% let len = name.len() %}
//!
//! {% let val -%}
//! {% if len == 0 -%}
//! {% let val = "foo" -%}
//! {% else -%}
//! {% let val = name -%}
//! {% endif -%}
//! {{ val }}
//! ```
//!
//! ## Filters
//!
//! Values such as those obtained from variables can be post-processed