can-stache
Version:
Live binding handlebars templates
47 lines (36 loc) • 1.16 kB
Markdown
@function can-stache.helpers.switch switch
@parent can-stache.htags 13
@signature `{{
Renders the `BLOCK` with contextual [can-stache.helpers.case] and [can-stache.helpers.default] helpers.
```html
{{
{{
<button value="edit"/>
{{/case}}
{{
<button value="view">
{{/case}}
{{
You do not have permission!
{{/default}}
{{/switch}}
```
@param {can-stache/expressions/key-lookup|can-stache/expressions/call} EXPRESSION An expression or key that references a value that will be switched on.
@param {can-stache.sectionRenderer} BLOCK a template that is rendered, uses [can-stache.helpers.case] and [can-stache.helpers.default] helpers to match `EXPRESSION`.
@body
## Use
The `switch` helper is used to render a block where one of several cases matches expr. It works just like a JavaScript switch.
```html
{{
{{
<can-import from="cart">
<cart-page></cart-page>
</can-import>
{{/case}}
{{
<can-import from="home">
<home-page></home-page>
</can-import>
{{/default}}
{{/switch}}
```