The #not block helper inverts a value's presence: it renders one expression when the input is empty, null, or undefined, and an optional {{else}} expression when the input has a non-empty value. Use it to display fallback messages or handle missing data.
Syntax
{{#not value}} expr {{else}} expr {{/not}}
value -- The field or value to evaluate. Required. If empty, null, undefined, false, or the integer 0, the main block renders. Otherwise, the {{else}} block renders.
Examples
Detect an empty string field
{{#not record.empty}}Field is empty{{else}}Field has value{{/not}}
Input:
{
"record": {
"isEnabled": true,
"empty": "",
"count": 0
}
}
Output: Field is empty
record.empty is an empty string, so the main block renders.
Detect a zero count
{{#not record.count}}No items available{{else}}Items exist{{/not}}
Input:
{ "record": { "count": 0 } }
Output: No items available
The integer 0 is treated as absent even though it has a value.
Empty arrays are treated as present
{{#not record.items}}No items{{else}}Items array exists{{/not}}
Input:
{ "record": { "items": [] } }
Output: Items array exists
An empty array [] is treated as present -- use the #isEmpty helper to check whether an array has no elements.
Usage notes
- Values treated as absent:
null,undefined, empty strings"",false, and the integer0. - Values treated as present: non-empty strings (including
"0"and"false"), non-zero numbers, objects, and arrays -- even empty arrays[]. - To check whether an array has no elements, use the #isEmpty helper instead.
- The
{{else}}clause is optional. If omitted and the value is present, the helper renders nothing.