{{#if key}}
can.stache.helpers.if
{{#if key}}BLOCK{{/if}}
Renders the BLOCK
template within the current template.
Parameters
-
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.
-
BLOCK
{can.stache(template)}
A stache template.
Returns
{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:
Rendered with:
Results in:
If can be used with {{else}} too. For example,
Rendered with:
Results in: