An introduction to Liquid at Mechanic
Everything in Mechanic is about tasks (see An introduction to tasks). Our tasks are written in Liquid – the same template language that Shopify uses for their online store themes, and for many other purposes.
Fundamentally, task scripts can be thought of as templates for rendering. (Liquid is a template language, after all!) Instead of rendering to prepare content for a web browser, Mechanic renders your task Liquid in response to incoming events (see An introduction to events) – and those events form the contextual data (read: template variables) that the task's Liquid needs to use.
The output of a rendered task isn't HTML – it's a series of JSON objects, each of which defines an action. Once the task is rendered, Mechanic reads each resulting action definition, and then runs each action. This is the part where Mechanic might make an API call to Shopify (the "shopify" action) or to an external services (the "http" action), or send an email (the "email" action), or a variety of other things (see An introduction to actions).
Additions to the language
A task only ever renders JSON objects. This can become tedious, so to make our lives easier here, we've introduced several new Liquid tags: action, log, and error. We've also enhanced the assign tag to support creating arrays and hashes.
To facilitate arrays and hashes, we added keyword literals for them as well: see Keyword literals.
Finally, we've added a bunch of filters: see Liquid filters. Highlights include "match" (for regular expressions), and "csv", "base64", "decode_base64", and "decode_json" for managing data.
Learning the system
The best way to learn is always to solve a problem. If you don't have a problem to solve yet, congrats! We've created some for you: see Practicing writing tasks. :)