A note on Slate syntax for merge fields
The examples in this article enclose merge fields in double curly braces inside conditions. For example, {% if {{major}} == 'Philosophy' %} starts a condition that uses the major merge field.
If your studies take you to the Shopify Liquid documentation (which we at times link to in our own), you may find that they use bare variables inside conditions, such as {% if product.title == "Awesome Shoes" %}. Use the Slate examples here for merge-field syntax and test examples that you adapt in the Slate tool where you will use them.
Existence exports
Offload complex comparisons to the query/recipient list as opposed to the mailing by leveraging an existence export. For instance, instead of using this nested Liquid markup:
{% if {{major}} == 'Philosophy'%}{% if {{school_state}} == 'Oregon' or {{address_state}} == 'Connecticut' %}This was tough!{% endif %}{% endif %}Add an existence export:
Allowing for easier comparison:
{% if {{philosophy_location}} == 'Y' %}Phew! That was much easier!{% endif %} Checking for empty or not empty merge fields
An existence export is ideal for determining if a field is or is not empty. Liquid markup may also be used in this case.
💡 In the syntax below
''is two single quotes with no space between them (an empty string).
{% if {{major}} == null or {{major}} == '' %}The major field is empty!{% endif %}{% if {{major}} != null and {{major}} != '' %}The major field is not empty!{% endif %}Display HTML content
For HTML data (e.g., an event description), add the rawhtml instruction to the Liquid markup merge field to display the output as HTML rather than text.
{{description | rawhtml}}This instruction is often used in a Liquid loop to display relevant data in a table format. The example below displays the event title, date, and description in a table row for every event returned by the events export or query node.
{% for event in events %}
{{event.title}}
{{event.date}}
{{event.description | rawhtml}}
{% endfor %}