{{^expression}}
Like {{#expression}}, but renders the opposite subsection depending on the type of expression or the expression’s return value.
Deprecated 4.15.0
Instead of using {{^}}
, use {{#}}
and not. For example,
instead of:
{{^ if(this.isOver18) }}
use:
{{# not(this.isOver18) }}
{{^EXPRESSION}}FN{{else}}INVERSE{{/key}}
Works just like {{#expression}}, but renders INVERSE
when it would have rendered the FN
block and vice-versa.
For example:
{{^ isOver18(person) }} Can’t Vote {{/isOver18}}
Renders Can’t Vote
if isOver18(person)
returns falsey
.
Parameters
- EXPRESSION
{Literal Expression|KeyLookup Expression|Call Expression|Helper Expression}
:An expression type. Behavior depends on the type of expression:
- KeyLookup Expression and Call Expressions:
- renders
FN
with falsey values and empty lists. - renders
INVERSE
with truthy values or each item in a list.
- renders
- Helper Expressions: switch the
options.fn
andoptions.inverse
.
- KeyLookup Expression and Call Expressions:
Use
Inverted sections match falsey values. An inverted section syntax is similar to regular sections except it begins with a caret rather than a pound. If the value referenced is falsey, the section will render. For example:
The template:
<ul>
{{#friends}}
</li>{{name}}</li>
{{/friends}}
{{^friends}}
<li>No friends.</li>
{{/friends}}
</ul>
And data:
{
friends: []
}
Results in:
<ul>
<li>No friends.</li>
</ul>