Liquid tags

Tags create the logic and control flow for templates. They are denoted by curly braces and percent signs: {% and %}.

Tags are really powerful and are used extensively in document layouts in Current RMS. They’re a way of performing logic operations and controlling flow in document layouts.

comment

Any content that you put between {% comment %} and {% endcomment %} tags is turned into a comment.

{% comment %} 
  The object below outputs our company name 
{% endcomment %}

<h1>{{ company.name }}</h1>

if/else/elsif

Use an if tag to determine whether content should be shown if a certain condition is true.

For example, you can check to see if a customer’s telephone number is blank and display a different message by adding a {% else %} depending on whether or not this is true.

{% if customer.telephone == blank %}
  We do not have a telephone number on record for you.
{% else %}
  {{ customer.telephone }}
{% endif %}

Use elsif to add more conditions. For example:

unless

An unless tag is the opposite of an if tag. It tells Current RMS to only show content if the condition isn’t met.

for

for loops run through items in a collection (array), e.g. opportunity items or contacts against an organisation.

In the example below, a list item is created for each item within the order.items loop – this is the list of items on an opportunity:

This might output something like:

  • ETC Source 4

  • Martin Mac Entour

  • Pioneer XDJ

  • Apple MacBook Pro

cycle

The cycle tag is used within a for loop. It’s a way of looping through a group of strings and outputting them in the order they were listed.

For example, we could run through order.items as above but have every other list item as italicized or bold:

This might output something like:

  • ETC Source 4

  • Martin Mac Entour

  • Pioneer XDJ

  • Apple MacBook Pro

assign

Use assign to create a variable. Variables are used to store information that you can reference and manipulate later.

For example:

Use quotation marks to save as a string:

capture

Use capture to capture something between the opening and closing tags and assign to a variable. Variables that you create are stored as strings.

{{ hello_message }} will then output something like:

case

Creates a switch statement to compare a variable with different values. caseinitializes the switch statement, and when compares its values.

Last updated

Was this helpful?