mirror of
https://github.com/askama-rs/askama.git
synced 2025-10-02 07:20:55 +00:00
Add assignments documentation
This commit is contained in:
parent
e7fde0733b
commit
c7fe975b27
@ -119,6 +119,27 @@
|
|||||||
//! while `{{ user.name }}` will get the ``name`` field of the ``user``
|
//! while `{{ user.name }}` will get the ``name`` field of the ``user``
|
||||||
//! field from the template context.
|
//! 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
|
//! ## Filters
|
||||||
//!
|
//!
|
||||||
//! Values such as those obtained from variables can be post-processed
|
//! Values such as those obtained from variables can be post-processed
|
||||||
|
Loading…
x
Reference in New Issue
Block a user