The #neither block helper renders one expression when both arguments are empty, null, or undefined, and an optional {{else}} expression when one or both arguments have a non-empty value. Use it to conditionally output content when two fields are both absent or empty.
Syntax
{{#neither field1 field2}} expr {{else}} expr {{/neither}}
field1, field2 -- Two fields or values to evaluate. If both are empty, null, or undefined, the main block renders. If either has a non-empty value, the {{else}} block renders. Required.
Examples
Render when both fields are empty
{{#neither item1 item2}}
Values are absent for the specified parameters.
{{else}}
Only one of the parameters has a value.
{{/neither}}
Input:
{
"item1": "",
"item2": ""
}
Output: Values are absent for the specified parameters.
Both item1 and item2 are empty strings, which are treated as absent. The main block renders.
Render the else branch when one field has a value
{{#neither item1 item2}}
Values are absent for the specified parameters.
{{else}}
Only one of the parameters has a value.
{{/neither}}
Input:
{
"item1": "",
"item2": "5"
}
Output: Only one of the parameters has a value.
item2 is truthy, so the {{else}} block renders even though item1 is empty.
Usage notes
- Values treated as absent:
null,undefined, empty strings, and the integer0. The string"0"is treated as present because it's a non-empty string. - The
{{else}}clause is optional. If omitted and either argument has a non-empty value, the helper renders nothing. - To render content when either argument is empty (not both), use the #and helper with an inverted condition instead.