The "action" tag
Because the ultimate purpose of a task is to generate actions, we offer a specialized Liquid tag as a quick shorthand for composing an action's JSON definition.
This article is about composing action definitions. For a more general introduction, learn more about actions.
Usage
Block syntax
This usage requires the string name of the action you wish to render, and a JSON value for the block content.
{% action "echo" %} "hello world!" {% endaction %} { "action": { "type": "echo", "options": "hello world!" } }
{% action "shopify" %} ["create", "customer", {"email": "hello@example.com"}] {% endaction %} { "action": { "type": "shopify", "options": [ "create", "customer", { "email": "hello@example.com" } ] } }
Statement syntax
This usage requires a the string name of the action you wish to render, followed by one of the following:
- A single string, numbers, or Liquid variable
- A comma-separated list of strings, integers, and/or Liquid variables
- A map of keys and values, where the values may be strings, numbers, or Liquid variables
{% action "echo" "hello world!" %} { "action": { "type": "echo", "options": "hello world!" } }
{% assign world = "world" %} {% action "echo" "hello", world %} { "action": { "type": "echo", "options": [ "hello", "world" ] } }
{% action "echo", hello: "world" %} { "action": { "type": "echo", "options": { "hello": "world" } } }
{% assign foo = '{"bar": "baz"}' | parse_json %} {% action "echo" foo %} { "action": { "type": "echo", "options": { "bar": "baz" } } }