can
Version:
MIT-licensed, client-side, JavaScript framework that makes building rich web applications easy.
57 lines (37 loc) • 1.16 kB
Markdown
#if key}}
can.stache.htags 2
`{{#if key}}BLOCK{{/if}}`
Renders the `BLOCK` template within the current template.
{can.stache.key} key A key that references a value within the current or parent
context. If the value is a function or can.compute, the function's return value is used.
{can.stache} BLOCK A stache template.
{String} If the key's value is truthy, the `BLOCK` is rendered with the
current context and its value is returned; otherwise, an empty string.
## Use
`{{#if key}}` provides explicit conditional truthy tests. For example,
The template:
{{#if user.isFemale}}
{{#if user.isMarried}}
Mrs
{{/if}}
{{#if user.isSingle}}
Miss
{{/if}}
{{/if}}
Rendered with:
{user: {isFemale: true, isMarried: true}}
Results in:
Mrs
If can be used with [can.stache.helpers.else {{else}}] too. For example,
{{#if user.isFemale}}
{{#if user.isMarried}}
Mrs
{{else}}
Miss
{{/if}}
{{/if}}
Rendered with:
{user: {isFemale: true, isMarried: false}}
Results in:
Miss
can.stache.helpers.if {{