Prerequisites
- Understanding of Placeholders
- Familiarity with Block types
- Basic knowledge of JSON arrays and objects
Directive types
| Directive | Purpose |
|---|---|
| #each | Loop over an array and generate repeating content |
| #if | Conditionally render content based on data |
| #block | Group blocks together (organizational) |
Using #each
The#each directive iterates over an array and generates blocks for each item.
Prepare your data
Ensure your sample data includes an array:Add and configure a directive container
- In the Template Builder, click Add Block
- Select Directive Container
- In the directive configuration panel:
- Directive Type:
#each - Array Path: path to your array (e.g.
items,order.items,data.results)
- Directive Type:
- Confirm
{{}}.
Add child blocks
Inside the directive container, add the blocks that repeat for each item (Section, Context, Actions, etc.):Placeholders inside the loop
{{this.property}}— property of the current item{{this}}— entire current item (for arrays of simple values like strings){{@index}}— zero-based index (0, 1, 2, …)
Order: {{order.id}} and Item: {{this.name}} together.
Optional: limit large lists
In the directive configuration, set Max Blocks (e.g. 5) and Overflow Text (e.g._... and {{remaining}} more items_) to avoid overly long messages.
Using #if
Use#if to show or hide content based on a value. Set Directive Type to #if, configure the Condition path (e.g. a boolean like has_error), and add child blocks. They render only when the condition is met.
Best practices
- Use clear array paths that match your sample data (e.g.
order.line_itemsinstead ofitems) - Keep loop content focused — one section or a small set of blocks per item
- Limit large lists with Max Blocks and overflow text
- Test with different array lengths (empty, one item, many items)
Next steps
Placeholders
Reference data with .
Block types
Combine directives with blocks.

