Liquid Reference

Liquid is a template language created by Shopify and written in Ruby. It is now available as an open source project on GitHub, and used by many different software projects and companies. Liquid is the backbone of all Shopify themes, and is used to load dynamic content to the pages of online stores. (Source: https://help.shopify.com/en/themes/liquid)

Designers and developers can use template language to combine static and dynamic content to populate pages with data from a Shopify store. Static elements are written in HTML and dynamic elements are written in Liquid.  

Infusionsoft's Broadcast Email and Campaign Builder's email are where Liquid syntax is currently available for use.

For more information on Liquid syntax please see the open source documentation on Shopify's Page.

Prior to Liquid Content, your campaign in Campaign Builder might look something like this...

After, your campaign may look like this: 

Double clicking on the Dynamic Content icon reveals this

Liquid Code Basics

Objects

  • Tell Liquid where to show content
  • Denoted by double curly or square braces: {{ and }} or [[ and ]]

Operators

  • ==    equal to
  • !=     not equal to
  • >      greater than
  • <      less than
  • >=    greater than or equal to
  • <=    less than or equal to
  • or     this OR that
  • and    must be this AND that
  • contains    contains

Tags

  • Create the logic and control flow for templates
  • Denoted by curly braces and percent signs: {% and %}

Filters

  • Change the output of a Liquid object
  • Used within an output and are separated by a |

Examples of Liquid

Liquid basic syntax

CodeResult
{{ contact.firstname }}George

Fallback Values (i.e.defaults)

CodeResult
Hi {{ contact.firstname | default: 'there' }}Hi George

If Contact does not have a first name: Hi there

Control flow tags - based on Number of Employees

CodeResult
{% if contact.numberofemployees > 50 %}With a large organization like yours, communication is key.
{% elsif contact.numberofemployees > 5 %}In SMBs, the key is balance.
{% else %}In a micro-org like yours, you need to save every dollar.
{% endif %}

Control flow tags - based on Email Domain

CodeResult
{% if contact.email1.address contains ‘@gmail.com’ %}<a href= "https://help.keap.com/help/gmail-sync">Gmail sync for Keap</a> captures the email communications in Gmail into your contact record.
{% else %}<a href= "https://help.keap.com/help/gmail-sync">Gmail sync</a> and <a href= "https://help.keap.com/help/microsoft-sync">Microsoft email sync</a> for Keap captures email communications into your contact records.
{% endif %}

Dates

CodeResult
{{ today.date }}2019-08-13
{{ today.date | short }}8/13/19
{{ today.date | medium }}Aug 13, 2019
{{ today.date | long }}August 13, 2019
{{ today.date | full }}Tuesday, August 13, 2019
{{ today.date | plus_days: 14 | full }}Tuesday, August 27, 2019

Case Statements

Hello ~Contact.FirstName~,

~Date.DayOfWeek~

{% capture day %}{{ 'now' | date: '%A' }}{% endcapture %}

{% case day %}

{% when 'Sunday' %} Check out our Sunday specials!

{% when 'Monday' %} Check out our Monday specials!

{% when 'Tuesday' %} Check out our Tuesday specials!

{% when 'Wednesday' %} Check out our Wednesday specials!

{% when 'Thursday' %} Check out our Thursday specials!

{% when 'Friday' %} Check out our Friday specials!

{% when 'Saturday' %} Check out our Saturday specials!

{% endcase %}

Was this article helpful?
Thank you for your feedback!