Add documentation for mutable variables

This commit is contained in:
Guillaume Gomez 2025-05-25 15:49:11 +02:00 committed by René Kijewski
parent 741ff53a88
commit 6010cd390f

View File

@ -63,6 +63,15 @@ Like Rust, Askama also supports shadowing variables.
{{ foo }}
```
You can declare variables as mutable with the `mut` keyword:
```jinja
{# In this example, `foo` is an iterator. If you want to be able to iterate it,
you need it to be mutable #}
{% let mut foo = [1, 2].iter() %}
{{ foo.next().unwrap() }}
```
For compatibility with Jinja, `set` can be used in place of `let`.
### Borrow rules