Handlebars Helper Function: and

Performs a logical AND operation between multiple values. Returns true if all values are truthy, and false otherwise.

Availability

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

Syntax

{{and value1 value2 [value3 value4 ...]}}

Parameters

Parameter Type Description
value1 Any The first operand for the AND operation.
value2 Any The second operand for the AND operation.
value3, value4, ... Any Additional operands to evaluate.

Return Value

The function returns true if all parameters evaluate to true, and false otherwise. If no parameters are provided, the function returns true. If one parameter is provided, the function returns the truthiness evaluation for that parameter.

Truthiness evaluation follows these rules:

  • null is false
  • Boolean values are evaluated as-is
  • Non-zero numbers are true, but zero is false
  • Empty strings are false, and non-empty strings are true
  • Empty arrays ([]) and empty objects ({}) are false

Usage Example

This function is often used together with conditional helpers to handle multiple conditions. For example, this code example checks if the user is both an admin and is active and handles it accordingly.

{{#if (and (equals user.role "admin") (compare user.status "==" "active"))}}
  <!-- Handle the case where the user is both an admin and is active -->
{{else}}
  <!-- Handle the case where the user isn't an admin, isn't active, or both -->
{{/if}}

See Also