Loops

Loops allow you to repeat a block of content for each item in an array. They are essential for rendering lists of recommendations, action items, policy details, and any repeated content in your documents.

Syntax

Use {{#each}} to open a loop and {{/each}} to close it. Everything between these tags is repeated for each item in the array.

Template syntax
{{#each recommendations}}
Recommendation: {{title}}
{{description}}

{{/each}}

Accessing the index

Use {{@index}} to access the zero-based index of the current item, or {{@number}} for a 1-based number.

Numbered list
{{#each action_items}}
{{@number}}. {{description}} — Due: {{due_date}}
{{/each}}

First and last items

You can use {{@first}} and {{@last}} to conditionally render content only for the first or last item in the loop. This is useful for adding separators or special formatting.

Example data

Data
{
  "recommendations": [
    {
      "title": "Consolidate superannuation",
      "description": "Roll over your existing super funds into a single account to reduce fees."
    },
    {
      "title": "Increase insurance cover",
      "description": "Review and increase life and TPD cover to match your current needs."
    },
    {
      "title": "Establish emergency fund",
      "description": "Set aside 3-6 months of expenses in a high-interest savings account."
    }
  ]
}

Empty arrays

If the array is empty, the loop block will not render any content. Wrap the loop in a conditional if you need to show a fallback message.