Liquid is an open source template language created by Shopify and written in Ruby. At Modyo we use this language to add dynamic capabilities to digital channels. Thanks to the fact that its rendering is performed server-side, we reduce the resource load on the client's side while optimizing the performance of our digital channels to the maximum.
Liquid uses a combination of objects, tags, and filters to transform static sites into sites with dynamic content by connecting the visual structures that are created in Channels with the data generated in Content or even segmenting that content according to the segmentations defined in Customers, all inside Modyo Platform.
Objects
Objects print Liquid content when used. Objects and variables are displayed when they are enclosed in double braces:
Liquid groups this into lists called Liquid Drops. For the full list of drops Modyo offers, see Drops in our documentation.
Tags
Tags create the logic and flow in the template, represented by the percentage and brace symbols, do not print any visible result when the template is rendered.
To see more examples on how to use tags, see Tags in our documentation.
Filters
A filter is a Ruby method that takes one or more parameters and returns a value. Parameters are passed to filters by position:
To see more examples on how to use filters, see Filters in our documentation.
Examples
Run JS code if you're in a page titled 'Home'
You can also use this if to run JS, HTML or CSS code.
Filter a date to only show the year:
The date format syntax is the same as strftime.
Split by spaces and print only the first object:
Print the object's size:
Truncate the object into the first 20 characters:
Create a variable containing Content entries of a specified space and type, and print their titles:
If you want to know more about Liquid, see their official documentation.
Photo by Bilal O. on Unsplash.