Objects and Comparisons
  • 15 Sep 2025
  • 2 minute read
  • Dark
    Light
  • PDF

Objects and Comparisons

  • Dark
    Light
  • PDF

Article summary

In Liquid markup, the fundamental unit we work with is the object.

Objects

Say you’re in a Slate location that provides access to merge fields, like the Edit Message interface in a Deliver mailing.

When you select a merge field, it is inserted at the position of your cursor as a Liquid object. For example, with the Recipient field selected, if you then select the Email merge field, the Liquid object {{Email}} appears at the location of the cursor.

When the mailing is sent, these placeholder Liquid objects are replaced with the data values they represent: {{Email}} becomes [email protected], {{First}} becomes Alexander, and so on.

Referencing a merge field value wrapped in curly brace delimiters {{ }} outputs the value represented by the merge field inside those delimiters.

Operators

Now that we know how to output values with Liquid, we can start to add tags that define the conditions under which they should appear. You can make these comparisons with operators.

These operators work in conjunction with the conditional tags:

Comparison operators

==

Evaluates as True if one value is equal to another value:

{% if {{major}} == 'Philosophy' %}
    Existentialism? Don't get us started!
{% endif %}

!=

Evaluates as True if one value is not equal to another value:

{% if {{major}} != 'Statistics' %}
    Probability is overrated!
{% endif %}

>=

Evaluates as True if the value on the left is greater than or equal to the value on the right:

{% if {{guests}} >= 10 %}
    Groups of 10 or more will need to ride in separate golf carts.
{% endif %}

>

Evaluates as True if the value on the left is greater than the value on the right:

{% if {{guests}} > 10 %}
    Groups of more than 10 will need to ride in separate golf carts.
{% endif %}

<

Evaluates as True if the value on the left is less than the value on the right:

{% if {{guests}} < 10 %}
    Groups of less than 10 will ride in the same golf cart.
{% endif %}

<=

Evaluates as True if the value on the left is less than or equal to the value on the right:

{% if {{guests}} <= 9 %}
    Groups of nine or less will ride in the same golf cart.
{% endif %}

contains

Evaluates as True if the value on the left contains the value on the right:

{% if {{major}} contains 'Science' %}
    Let us tell you more about the seduction of scientific deduction!
{% endif %}

Boolean operators

Multiple comparisons can be made in the same evaluation using the and & or Boolean operators:

and

Evaluates as True if both expressions evaluate as True:

{% if {{major}} == 'Philosophy' and {{degree}} == 'Doctorate' %}
    So we take it you're serious about Philosophy?
{% endif %}

or

Evaluates as True if at least one expression evaluates as True:

{% if {{major}} == 'Philosophy' or {{major}} == 'Political Science' %}
    Debate is in your future
{% endif %}

πŸ“ Note

Boolean expressions are always evaluated from right to left in Liquid.

Truthiness and falsiness

When you work with Boolean operators in Liquid, it’s worth understanding the conditions under which an expression will evaluate as True and when it will evaluate as False. For example, an empty string will evaluate in a comparison as True, meaning empty strings are truthy values.

πŸ“– Truthy and falsy in Liquid


Was this article helpful?