mirror of
https://github.com/askama-rs/askama.git
synced 2025-09-30 06:21:13 +00:00
Update book/src/template_syntax.md
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
This commit is contained in:
parent
1a74d9350e
commit
6e75cb0802
@ -594,10 +594,7 @@ and the same restrictions as in Rust, e.g. that it can be used only once in a sl
|
||||
```
|
||||
|
||||
The `{% else %}` node is syntactical sugar for `{% when _ %}`.
|
||||
If used, it must come last, after all other `{% when %}` blocks.
|
||||
A `{% match %}` must be exhaustive, i.e. all possible inputs must have a case.
|
||||
This is most easily done by using proving an `{% else %}` case,
|
||||
if not all possible values need an individual handling.
|
||||
If used, it must come last, after all other `{% when %}` blocks:
|
||||
|
||||
```jinja
|
||||
{% match answer %}
|
||||
@ -606,6 +603,10 @@ if not all possible values need an individual handling.
|
||||
{% endmatch %}
|
||||
```
|
||||
|
||||
A `{% match %}` must be exhaustive, i.e. all possible inputs must have a case.
|
||||
This is most easily done by using proving an `{% else %}` case,
|
||||
if not all possible values need an individual handling.
|
||||
|
||||
Because a `{% match %}` block could not generate valid code otherwise,
|
||||
you have to provide at least one `{% when %}` case and/or an `{% else %}` case.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user