Usage: {{#match @custom.color_scheme "=" "Dark"}} class="dark-mode"{{/match}}
{{#match}}
allows for simple comparisons, and executing different template blocks depending on the outcome.
Like all block helpers, {{#match}}
supports adding an {{else}}
block or using ^
instead of #
for negation - this means that the {{#match}}
and {{else}}
blocks are reversed if you use {{^match}}
and {{else}}
instead. In addition, it is possible to do {{else match ...}}
, to chain together multiple options like a switch statement.
match
helper is handy when paired with custom theme settings using @custom
:
=
- equals (default when no operator provided)!=
- not equals>
- greater than>=
- greater than or equals<
- less than<=
- less than or equals~
- contains~^
- starts with~$
- ends withmatch
supports comparing values for equality, which is the default behaviour:
~
, starts with ~^
and ends with ~$
, using the same syntax as NQL filtering
>
, <
, >=
and <=
operators for numeric comparisons.
match
are tested according to their value as well as their type. For example:
match
can also be used to test boolean values similar to if
: