Handlebars Helpers
Switch
Renders the matching case for a value
The switch helper compares a value against nested case helpers and renders the content of the first matching case.
Uses
- Use to choose one output from a list of known values
- Use instead of multiple nested
ifblocks when matching against exact values
Usage
Helper name : switch
eg.
{{#switch [value]}}{{#case "matching value"}}output{{/case}}{{/switch}}
Examples
Example definition:
Action context:
Substituted definition
Example Matching a Different Case
Example definition:
Action context:
Substituted definition