🐙 Check out Postmark's new MCP Server!
x
How Parent and Child Variables Work in Postmark Templates | Postmark Support Center

How Parent and Child Variables Work in Postmark Templates

When you’re using Postmark Templates—especially for things like receipts, summaries, or daily digests—you’ll often work with parent and child variables.


Here’s what that means, and how to use them effectively.


🧱 The Basics

Postmark templates use a simple templating language called Handlebars, which lets you insert variables directly into your HTML.

For example:

<p>Hi {{name}}!</p>

When you send data like this:

{
  "name": "Ava"
}

Your template will render as:

Hi Ava!

🔁 Example: Looping Through Items

Let’s say you want to display a list of products in an order confirmation or a daily summary email.
Here’s what your JSON data might look like:

{
  "name": "Ava",
  "items": [
    { "title": "Toothbrush", "price": "$2.50" },
    { "title": "Towel", "price": "$7.00" }
  ]
}

In this case, items is the parent variable (an array), and title and price are the child variables inside each object.

Here’s how you would loop through them in your template:

<p>Hi {{name}}, here’s your order:</p>
<ul>
  {{#each items}}
    <li>{{title}} – {{price}}</li>
  {{/each}}
</ul>

When your email is sent, it will render as:

Hi Ava, here’s your order:

• Toothbrush – $2.50  
• Towel – $7.00

📌 Tips for Working With Loops

Tip Why it matters
Use #each parentArray to start the loop Tells Postmark you’re looping through a list of objects
Inside the loop, use {{childProperty}} Postmark knows these are keys inside each object
Don’t use items.title inside the loop You don’t need to reference the parent again
Use if and else inside loops Great for showing fallback text if the list is empty

🛠 Example: Showing an Empty State

You can add conditional logic to display a message if there are no items to show:

{{#if items.length}}
  {{#each items}}
    <p>{{title}} – {{price}}</p>
  {{/each}}
{{else}}
  <p>No items to display.</p>
{{/if}}

If your items array is empty, your template will display:

No items to display.

📚 Learn More

For a full breakdown of Postmark’s template syntax, check out our documentation:
👉 Template Syntax Guide

Last updated October 20th, 2025

Still need some help?

Our customer success team has your back!