Homepage

Liquid Markup - Introduction

Last edit: Sep 16, 2023

Liquid, also known as Liquid markup, is a template language employed within platformOS for crafting dynamic pages and facilitating dynamic configurations, such as adjustments based on the currently logged-in user. Many renowned companies and software, including Microsoft, Shopify, Zendesk, Jekyll, and many others, utilize Liquid in their applications. Use Liquid to establish authorization policies, or to define notifications through email, SMS, or API calls. To further streamline your experience, we've incorporated a wide array of filters and tags.

Note

Liquid has a new syntax — visit the documentation of the liquid tag for an example. We are updating all of our Liquid code examples to reflect this change.

Output

Output markup (which may resolve to text) is surrounded by


{{ matched pairs of curly brackets (ie, braces) }}

Example


{{ user.name }} => John

Tags

Tag markup (which cannot resolve to text) is surrounded by


{% matched pairs of curly brackets and percent signs %}

Example


{% if user %}
  true
{% endif %}

Filters

Liquid filters are simple methods that modify the output of numbers, strings, variables, and objects.

Simple use case


{{ "honda crx" | upcase }} => HONDA CRX

Arguments

Some filters accept arguments, for example, the replace filter accepts two:


{{ 'Hello liquid' | replace: 'liquid', 'world!' }} => Hello world!

Chaining

Having a verbose version of code that will:

  1. Create string with words
  2. Prepend "Zero," in front of the string
  3. Append ",Five" string at the end
  4. Split it by comma to create an array of strings
  5. Print it to the source

{% assign numbers = 'One,Two,Three,Four' %}
{% assign numbersWithZero = 'One,Two,Three,Four' | prepend: 'Zero,' %}
{% assign all_numbers = numbersWithZero | append: ',Five' %}
{% assign all_numbers_array = all_numbers | split: ',' %}
{{ all_numbers_array }} => ZeroOneTwoThreeFourFive

You can achieve the same result in much shorter form by chaining the filters one after another:


{{ 'One,Two,Three,Four' | prepend: 'Zero,' | append: ',Five' | split: ',' }} => ZeroOneTwoThreeFourFive

Raw

If you want to use liquid text on your page but without executing it, use {% raw %} ... {% endraw %} syntax.

Comment

Allows you to leave un-rendered code inside a Liquid template. Any text within the opening and closing comment blocks will not be output, and any Liquid code within will not be executed.

Input


Anything you put between {% comment %} and {% endcomment %} tags
is turned into a comment.

Output

Anything you put between  tags
is turned into a comment.

You can also use comment inside the liquid tag:


{% liquid
  comment
    This is is my code comment
  endcomment
  echo 'This is not a comment'
%}

Questions?

We are always happy to help with any questions you may have.

contact us