can
Version:
MIT-licensed, client-side, JavaScript framework that makes building rich web applications easy.
35 lines (21 loc) • 937 B
Markdown
stache.helpers.switch {{#switch expr}}
can.stache.htags 13
`{{#switch expr}}BLOCK{{/switch}}`
Renders the `BLOCK` with contextual [can.stache.helpers.case] and [can.stache.helpers.default] helpers.
{can.stache.expression} expr An expression or key that references a value that will be switched on.
{can.stache} BLOCK a template that is rendered, uses [can.stache.helpers.case] and [can.stache.helpers.default] helpers to match `expr`.
{DocumentFragment} A fragment containing the rendered `BLOCK`.
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}}
can.