{{#switch expression}}
function
{{#switch EXPRESSION}}BLOCK{{/switch}}
Renders the BLOCK with contextual {{#case expression}} and {{#default}} helpers.
{{#switch user.type}}
{{#case "admin"}}
Pay
{{/case}}
{{#case "admin"}}
<button/>
{{/case}}
{{#default}}
Look at data
{{/default}}
{{/switch}}
Parameters
- EXPRESSION
{KeyLookup Expression|Call Expression}:An expression or key that references a value that will be switched on.
- BLOCK
{sectionRenderer(context, helpers)}:a template that is rendered, uses {{#case expression}} and {{#default}} helpers to match
EXPRESSION.
Use
The switch helper is used to render a block where one of several cases matches expr. It works just like a JavaScript switch.
{{#switch page}}
{{#case "cart"}}
<can-import from="cart">
<cart-page></cart-page>
</can-import>
{{/case}}
{{#default}}
<can-import from="home">
<home-page></home-page>
</can-import>
{{/default}}
{{/switch}}