Liquid Basic Syntax guide

  • Updated
Description

This will show some basic functionality when it comes to using the syntax for Liquid coding.

 
Steps

When using liquid code directly in the Email Designed (content, URL, Subject) - if you are adding raw code simply enclose the Liquid code statement in a double curly brace {{   }}

 

  • All logic is enclosed with “{%” and “%}”
  • Use double curly braces to display what you assign: {{ and }} 
  • Example: For use with coupon codes;

In panel A ‘amt1’ is assigned the value ‘$10 OFF $100’. 

In panel B, ‘amt1’ is being referenced. When the campaign is previewed or sent out, ‘{{ amt1 }}’ will show the value it was assigned.

A.

B.

 

Variable assignment

    • {% assign myVar = ‘hello there’ %} 
    • {{myVar}} in the Email Designer will print “hello there”
  • Conditional statements

    • {% assign myVar = ‘hello’ %}
    • {% assign a = 2 %}
    • {% if a > 2 %}
    • {% assign myVar = ‘goodbye’ %}
    • {% endif %}
    • {{myVar}} will print “hello”
  • Caveats in ODP

    • In lookups, you must use ‘=~’ or ‘!=~’ with wildcards (*)to designate matching/not matching
      • Everywhere else, including Setup blocks, Conditions, and Variable sections, you can use ‘contains’ to find a matching value
      • Note: there is no ‘does not contain’ operator in Liquid
    • Money is not supported in Zaius, use this to format numbers to have two decimal points
      • {%if product.price != blank %}${{'%0.2f' | format: product.price }}{% else %}{% endif %}

 

Additional Resources