Everything in Mechanic is about tasks, and tasks are written in Liquid – the same template language that Shopify uses for their online store themes, and for many other purposes.
Fundamentally, task code is a Liquid template for rendering JSON instructions for actions. In the same way that a Liquid theme might take Shopify store data and render HTML for a web browser, Mechanic task code takes incoming events, and uses them as variables to render JSON objects, defining work to be performed.

Liquid basics

Mechanic's implementation of Liquid is based on the same engine that Shopify uses, which means that Mechanic shares the same basic Liquid features as Shopify does.

Mechanic's additions

Task code only ever renders JSON objects. To make it easier to generate JSON, we've introduced several new Liquid tags: action, log, and error.
Mechanic has first-class support for arrays and hashes, via new keyword literals that make it easy to instantiate them. We've also enhanced the assign tag to support assigning values within arrays and hashes.
We've added several filters that make it easier to manage data in the Mechanic world. Highlights include match (for regular expressions), and csv, base64, and decode_json.
Finally, Mechanic task code frequently interacts with special variables that Mechanic creates, representing specific types of data. These variables are examples of Mechanic-powered Liquid objects, which contain more intelligence than the usual Liquid variable.
Last modified 2yr ago