Handlebars Helper Function: if

Conditionally renders a block based on whether a value evaluates to true. This built-in helper is provided by the Handlebars.Net library.

Availability

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

Syntax

{{#if condition}}
  <!-- Content when condition evaluates to true -->
{{else if condition2}}
  <!-- Content when condition2 evaluates to true -->
{{else}}
  <!-- Content when condition and condition2 evaluate to false -->
{{/if}}

Parameters

Parameter Type Description
condition Any Required. The value to evaluate.

Return Value

The function renders the block template if the condition evaluates to true. If an {{else}} block is provided, it renders that block when the condition evaluates to false. The helper also supports {{else if}} blocks for multiple conditions.

See Also