Skip to content

Commit

Permalink
Update book/src/template_syntax.md
Browse files Browse the repository at this point in the history
Co-authored-by: Guillaume Gomez <[email protected]>
  • Loading branch information
Kijewski and GuillaumeGomez authored Aug 13, 2024
1 parent 1a74d93 commit 6e75cb0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions book/src/template_syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand All @@ -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.

Expand Down

0 comments on commit 6e75cb0

Please sign in to comment.