Skip to main content

Liquid Syntax in Text Editor

Liquid is a language that lets you create templates with dynamic content. It uses placeholders like {{ variable }} to insert data, and tags like {% if condition %} to add logic. This makes it easy to create personalized messages, emails, and more.

Key Features:​

  • Placeholders: Insert dynamic data, e.g., {{ person.name }}.
  • Filters: Modify data, e.g., {{ price | round }}.
  • Logic: Add conditions, e.g., {% if person.vip %}...{% endif %}.
  • Loops: Repeat content, e.g., {% for item in cart %}...{% endfor %}.

How to Use​

The Text Editor makes it easy to use Liquid syntax. Here’s how you can get started:

1. Insert Placeholders​

Placeholders let you insert dynamic data into your template. For example:

  • Template:
    Hello, {{ person.first_name }}!
  • Data:
    {
    "person": {
    "first_name": "Jane"
    }
    }
  • Result:
    Hello, Jane!

2. Preview Your Template​

As you type, the Text Editor shows a live preview of your template. This helps you see how your content will look with real data.

3. Add Logic​

You can use Liquid tags to add conditions. For example:

  • Template:
    {% if person.vip %}
    Welcome back, VIP {{ person.first_name }}!
    {% else %}
    Hello, {{ person.first_name }}!
    {% endif %}
  • Data:
    {
    "person": {
    "first_name": "Jane",
    "vip": true
    }
    }
  • Result:
    Welcome back, VIP Jane!

4. Use Loops​

Loops let you repeat content for a list of items. For example:

  • Template:
    Recent events:
    {% for event in trigger.events %}
    - {{ event.name }} at {{ event.timestamp }}
    {% endfor %}
  • Data:
    {
    "trigger": {
    "events": [
    { "name": "Login", "timestamp": "2026-01-20T10:00:00Z" },
    { "name": "Purchase", "timestamp": "2026-01-20T11:00:00Z" }
    ]
    }
    }
  • Result:
    Recent events:
    - Login at 2026-01-20T10:00:00Z
    - Purchase at 2026-01-20T11:00:00Z

Tips​

  1. Start Simple: Begin with basic placeholders and add complexity as needed.
  2. Preview Often: Use the live preview to check your work.
  3. Use Real Data: Test your templates with realistic data to ensure accuracy.
  4. Keep It Clear: Write templates that are easy to read and understand.

Important Note​

When rendering templates, data from the Sample Data tab takes precedence over data from the Attributes and Event Data tabs. This means that if the same variable exists in multiple sources, the value from the Sample Data tab will be used. Ensure your Sample Data is accurate and complete for the best results.

Allowed Data Structures​

At the moment, only the following data structures are supported in the Text Editor:

  • Person: Use {{ person }} to access person-related data.
  • Event: Use {{ event }} to access event-related data.
  • Trigger: Use {{ trigger }} to access trigger-related data like transactionals.

Ensure your templates are designed using these structures for compatibility.


Common Questions​

What happens if my template has an error?
If there’s a mistake in your Liquid syntax, the Text Editor will show an error message. Fix the error and try again.

Can I use Liquid for emails?
Yes! Liquid is perfect for creating personalized emails. Use placeholders for names, dates, and other details.

How do I test my template?
Use the live preview feature in the Text Editor. You can also provide sample data to see how your template will look.

Can I combine person, event, and trigger data in one template?
Yes, you can use all three data structures in a single template. For example:

Hi {{ person.first_name }},
Your recent event was {{ event.name }} triggered by {{ trigger.name }}.

What if my data is missing?
If a placeholder references missing data, the Text Editor will leave it blank in the preview. Ensure your sample data includes all required fields.

How do I handle dates in my templates?
You can use Liquid filters to format dates. For example:

{{ event.timestamp | date: "%B %d, %Y" }}

This will format the date as "January 20, 2026."

Can I use nested data structures?
Yes, you can access nested data. For example:

{{ person.address.city }}

This will display the city from the person’s address.


Examples​

Welcome Message​

  • Template:
    Hi {{ person.first_name }},
    Welcome to our service! Your last event was {{ event.name }}.
  • Data:
    {
    "person": {
    "first_name": "John"
    },
    "event": {
    "name": "Login"
    }
    }
  • Result:
    Hi John,
    Welcome to our service! Your last event was Login.

Order Confirmation​

  • Template:
    Thank you for your order, {{ person.first_name }}!
    Your items:
    {% for item in event.items %}
    - {{ item.name }}: ${{ item.price }}
    {% endfor %}
  • Data:
    {
    "person": {
    "first_name": "Jane"
    },
    "event": {
    "items": [
    { "name": "Book", "price": 10 },
    { "name": "Pen", "price": 2 }
    ]
    }
    }
  • Result:
    Thank you for your order, Jane!
    Your items:
    - Book: $10
    - Pen: $2

Trigger Notification​

  • Template:
    Hi {{ person.first_name }},
    A new trigger occurred: {{ trigger.name }}.
  • Data:
    {
    "person": {
    "first_name": "Alice"
    },
    "trigger": {
    "name": "Email Opened"
    }
    }
  • Result:
    Hi Alice,
    A new trigger occurred: Email Opened.

By using Liquid syntax in the Text Editor, you can create dynamic, personalized content with ease. Start experimenting today!