Skip to main content
Directives expand or omit child blocks when a template compiles. Add a Directive from the toolbox and configure it in the editor; they are not inline Handlebars tags.

Repeat an array

1

Add sample data

Add an items array to the template’s Sample Data:
2

Configure the container

Add a Directive block, select each, and set Array Path to items, without placeholder braces. Add a Section as its child.
3

Write the repeating content

Preview with zero, one, and several items. The root order_id remains available inside the loop.
Set Max Blocks to limit repeated content and Overflow Text to a message such as and {remaining} more items. The overflow token has a single pair of braces. Each item can generate multiple blocks, so also check the total compiled message against limits. An empty array produces no repeated children. A missing or non-array source is an error; supply [] when there are no items.

Show content conditionally

Select if, specify a condition path, and choose an operator. The true branch is children; message templates can also supply elseChildren. Set negate: true to invert the result. Comparison operators need compareValue. Non-numeric values for a numeric comparison produce an error. This complete block shows different content for an approved request:
Use sample data { "status": "approved" } and then { "status": "pending" } to exercise both branches.
Modal directives have a narrower contract: modal if checks a truthy dot path and does not support the message operator table or elseChildren. Validate modals separately. The editor’s organizational block directive is disabled; use each and if for editor-authored workflows.

Nested containers

A child container can reference data available in its parent context. Keep nesting shallow, use explicit paths, and test the expanded result. An inner loop replaces this with its own item; do not assume this still points at the outer item. For API authoring, read GET /v1/templates/block-schema and run POST /v1/templates/validate before saving. See API authoring and template design.