Liquid Template Engine

Liquid Template Engine

Liquid is a templating engine that allows you to enable your users to quickly and easily customize your views at run-time while maintaining the safety, security, and integrity of your servers.

Liquid Syntax
In liquid, there are two different types of markup.

The first type of markup is output markup, is denoted by double sets of curly braces.

1
Hi {{ user.name }}

The second type of markup is tag markup, is typically used for logic and control structures such as loops.

1
2
3
4
5
<ul>
  {% for user in users %}
    <li>{{ user.name }}</li>
  {% endfor %}
</ul>

You can do basic if statements as well:

1
2
3
4
5
6
7
{% if user.name != 'JingLong' %}
  Hi JingLong!
{% elsif user.name == 'Bunlong' %}
  Hey Bunlong!
{% else %}
  Hello {{ user.name }}
{% endif %}

List of All of the Tags Available in Liquid

Tag Description
assign Assigns some value to a variable.
capture Block tag that captures text into a variable.
case Block tag, its the standard case…when block.
comment Block tag, comments out the text in the block.
cycle Cycle is usually used within a loop to alternate between values, like colors or DOM classes.
for For loop.
if Standard if/else block.
include Includes another template; useful for partials.
raw Temporarily disable tag processing to avoid syntax conflicts.
unless Mirror of if statement.


So far so good, That’s it! See ya! :)