can-stache
Version:
Live binding handlebars templates
49 lines (35 loc) • 1.36 kB
Markdown
-stache.helpers.eq eq
can-stache.htags
Render something if two values are equal.
`{{#eq([EXPRESSION...])}}TRUTHY{{else}}FALSY{{/eq}}`
Renders the `TRUTHY` section if every `EXPRESSION` argument is equal (`===`).
```html
<my-demo></my-demo>
<script type="module">
import {StacheElement} from "can";
class MyDemo extends StacheElement {
static view = `
{{# eq(this.state, 'loggedIn') }}
<button on:click="this.state ='loggedOut'">Log Out</button>
{{else}}
<button on:click="this.state = 'loggedIn'">Log In</button>
{{/ eq }}
`;
static props = {
state: ""
};
}
customElements.define("my-demo", MyDemo);
</script>
```
`eq` can compare more than two values:
```html
{{# eq(task.ownerId, task.assignedId, user.id) }} Delegate! {{/ eq }}
```
{can-stache/expressions/literal|can-stache/expressions/key-lookup|can-stache/expressions/call} [EXPRESSION] Two or more expressions whose return values will be tested for equality.
{can-stache.sectionRenderer} TRUTHY A subsection that will be rendered if each
`EXPRESSION` argument eq equal.
{can-stache.sectionRenderer} [FALSY] An optional subsection that will be rendered
if one of the `EXPRESSION` arguments is not equal to one of the others.
can