Using Liquid on Modyo

Felipe Meyer

Felipe Meyer

 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.

Other Developer Tips

Insights
Carlos Solís

Carlos Solís

Strategies for reverting changes in production

Writing code is a complex task that, despite having quality control systems and peer reviews, always carries the risk of an error reaching production, learn the strategies to avoid these issues and clear methods to revert errors when they occur.

Tutorial
Carlos Solís

Carlos Solís

How to use reCaptcha on Modyo

In today's digital world, safeguarding websites against spam and malicious automated access is more crucial than ever and reCAPTCHA has become an essential tool in this effort.

Tutorial
Carlos Solis

Carlos Solis

Get started with the Dynamic Framework

If you want to accelerate the development process of your web applications, Dynamic framework is an open-source option that can assist you in crafting experiences optimized for the financial sector.