Skip to content

Types

Experience Builder's liquid system contains the following types.

  1. Nil
  2. Empty
  3. Blank
  4. Array
  5. Boolean
  6. Dictionary
  7. Number
  8. String
  9. DateTime

Nil

Represents a null or absent value in Experience Builder. It is equivalent to null in many programming languages. This type is typically used to denote an absence of value and does not participate in any meaningful operations.

Example:

    {% assign value = nil %}
    {{ value }}
Output:
    An empty output since value is `nil`.

Empty

Denotes a value that represents "nothing", but different from nil. Commonly used to represent an uninitialized variable.

  • Type: Empty

Example:

    {% assign value = empty %}

    {{ value }}
Output:
    An empty output since value is defined yet contains no data.

Blank

Represents a value similar to empty, but generally used with strings and arrays to signify they contain no meaningful data (e.g., an empty string or whitespace).

  • Type: Blank

Example: ```

{{ value | default: 'Default Value' }}

**Output**: Default Value ```

Array

Stores a collection of values.

  • Type: Array

Example:

    {% assign colors = "red, blue, green" | split: ", " %}
    {{ colors | join: " | " }}
Output:
    red | blue | green

Boolean

Represents true or false states.

  • Type: Boolean

Example:

    {% assign condition = true %}
    {% if condition %}
    The condition is true.
    {% else %}
    The condition is false.
    {% endif %}
Output:
    The condition is true.

Dictionary

Key-value pairs collection.

  • Type: Dictionary

Example:

    {% assign user = {"name": "John Doe", "age": 30} %}
    {{ user.name }}, Age: {{ user.age }}
Output:
    John Doe, Age: 30

Number

Represents numeric values.

  • Type: Number

Example:

    {% assign a = 10 %}
    {% assign b = 25 %}
    Sum: {{ a | plus: b }}
Output:
    Sum: 35

String

Textual data.

  • Type: String

Example:

    {% assign text = "Hello, World!" %}
    {{ text }}
Output:
    Hello, World!

DateTime

Represents date and time values.

  • Type: DateTime

Example:

    {% assign current_time = "2023-05-01 10:00:00" | date: "u" %}
    {{ current_time }}
Output:
    2023-05-01 10:00:00Z

Key Points

  1. Boolean Aliases: The types Blank, Empty, and False behave similarly when evaluated in conditional checks.
  2. Array Indexing: Accessing array items out of bounds returns Nil.
  3. Dictionary Default Values: Attempting to access non-existent keys in a dictionary will return Nil.
  4. DateTime Formatting: Provides powerful manipulation and formatting capabilities using Liquid filters.
  5. Type Conversion: Implicit conversion happens in complex operations, like adding Number and String types leading ultimately to a String.
  6. Outliers: Particular attention needs to be given to Nil and Empty as they can affect logical operations heavily due to their inherent nature of representing "absence of value." Usage in loops or conditionals may lead to unexpected behaviors, especially in nested constructs.