Handlebars Helper Function: iif

Evaluates an expression and returns one of two values based on whether the expression is true or false. This function works similarly to a ternary operator in other programming languages.

Availability

This helper is available in the Winter ’26 release of Marketing Cloud Next.

Syntax

{{iif expression leftResult rightResult}}

Parameters

Parameter Type Description
expression Any Required. The expression to evaluate.
leftResult Any Required. The value to return if the expression evaluates to true.
rightResult Any Required. The value to return if the expression evaluates to false.

Return Value

The function returns leftResult if the expression evaluates to true according to truthiness rules, otherwise returns rightResult. Truthiness evaluation follows these rules: null is false; boolean values are returned as-is; 0 is false, any non-zero number is true; empty string "" is false, any non-empty string is true; empty arrays [] and empty objects {} are false. Both leftResult and rightResult are always evaluated, regardless of which is returned.