Skip to content

Commit 028c27b

Browse files
Add documentation for | operator in when
1 parent 6a440dd commit 028c27b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

book/src/template_syntax.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,15 @@ if not all possible values need an individual handling.
610610
Because a `{% match %}` block could not generate valid code otherwise,
611611
you have to provide at least one `{% when %}` case and/or an `{% else %}` case.
612612

613+
You can also match against multiple alternative patterns at once:
614+
615+
```jinja
616+
{% match number %}
617+
{% when 1 | 4 | 86 %} Some numbers
618+
{% when n %} Number is {{ n }}
619+
{% endmatch %}
620+
```
621+
613622
### Referencing and dereferencing variables
614623

615624
If you need to put something behind a reference or to dereference it, you

0 commit comments

Comments
 (0)