Usage: {{#match @custom.color_scheme "=" "Dark"}} class="dark-mode"{{/match}}
Description
{{#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.
Operators
Equality
match
supports comparing values for equality, which is the default behaviour:
The equality test can also be negated:
Numeric comparisons
The match handler supports >, <, >= and <= operators for numeric comparisons.
Evaluation rules
Values passed to 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
:
Example code
The match
helper is extremely useful when combined with Custom settings using @custom
: