Articles in this section

#or helper

The #or block helper renders one expression when at least one argument has a non-empty value, and an optional {{else}} expression when both arguments are empty, null, or undefined. Use it to display content when either of two fields is present.

Syntax

{{#or field1 field2}} expr {{else}} expr {{/or}}

field1, field2 — Two fields or values to evaluate. If either has a non-empty value, the main block renders. If both are empty, null, or undefined, the {{else}} block renders. Required.

Examples

Render when at least one field has a value

{{#or item1 item2}}
 One or both fields have a data value.
{{else}}
 Neither field has a data value.
{{/or}}

Input:

{
 "item1": "100",
 "item2": "15000"
}

Output: One or both fields have a data value.

Both fields have non-empty values, so the main block renders.

Render the else branch when both fields are empty

Same template as above.

Input:

{
 "item1": "",
 "item2": ""
}

Output: Neither field has a data value.

Both fields are empty strings, so the {{else}} block renders.

Usage notes

  • The main block renders if either or both arguments have a non-empty value — not only when exactly one does.
  • Values treated as absent: null, undefined, empty strings, and the integer 0.
  • The string "0" is treated as present because it's a non-empty string.
  • The {{else}} clause is optional. If omitted and both arguments are empty, the helper renders nothing.
  • To render content only when both fields have a non-empty value, use the #and helper instead.
  • To render content when both fields are absent, use the #neither helper instead.