mirror of
https://github.com/askama-rs/askama.git
synced 2025-09-28 13:30:59 +00:00
Add documentation for mutable variables
This commit is contained in:
parent
741ff53a88
commit
6010cd390f
@ -63,6 +63,15 @@ Like Rust, Askama also supports shadowing variables.
|
|||||||
{{ foo }}
|
{{ 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`.
|
For compatibility with Jinja, `set` can be used in place of `let`.
|
||||||
|
|
||||||
### Borrow rules
|
### Borrow rules
|
||||||
|
Loading…
x
Reference in New Issue
Block a user