Operators

Overview

ZML includes many logical and comparison operators.

Operator

Description

==

equals

!=

does not equal

>

greater than

<

less than

>=

greater than or equal to

<=

less than or equal to

or

logical or

and

logical and

Example

{% if color_preference == "red" %}

You prefer red things!

{% endif %}

Multiple operators are permitted as well:

{% if color_preference == "red" or color_preference == "blue" %}

You prefer red or blue things!

{% endif %}

Contains

contains checks for the presence of a substring inside a string.

{% if recipient_email contains "@gmail.com" %}

You use gmail!

{% endif %}

contains can also check for the presence of a string in an array of strings. Assuming we have an array called subscription_preferences:

{% if subscription_preferences contains "newsletter" %}

You are subscribed to newsletters.

{% endif %}

contains can only search strings. You cannot use it to check for an object in an array of objects.