Dynamic Content Overview
Learn how PostBrix powers dynamic templating with Handlebars: variables, loops, conditional visibility, and sample data preview.
Key Takeaways
- PostBrix uses standard Handlebars ({{curly braces}}) syntax for dynamic templating.
- Separate template design from dynamic data: build once, populate with millions of personalized payloads.
- Supports single variables, nested objects, conditional blocks (if/else), and repeating collection loops (each).
- Dynamic tags are preserved on export for server-side hydration or translated into your ESP syntax.
The PostBrix Dynamic Model#
In high-volume transactional and lifecycle marketing, emails are rarely static. Receipts, shipping notifications, abandoned cart alerts, and weekly digests all depend on dynamic data injected at send time.
PostBrix decouples email design from runtime data:
- Design in PostBrix: Create your layout and place dynamic merge tags (like
{{user.firstName}}or{{order.total}}) where personalized content belongs. - Preview with Sample JSON: Supply mock data in the editor to visually test edge cases (long names, missing values, empty arrays) before exporting.
- Render at Scale: Either export the template with preserved dynamic tags into your sending platform, or call the PostBrix Render API to compile fully hydrated HTML programmatically.
Built on Handlebars#
PostBrix templates utilize the battle-tested Handlebars.js templating engine.
Key characteristics:
- Double Curlys:
{{variable}}evaluates and HTML-escapes strings to prevent cross-site scripting (XSS) injection. - Triple Curlys:
{{{rawHtml}}}outputs unescaped HTML (use with caution for rich formatted content). - Block Helpers:
{{#if}},{{#unless}}, and{{#each}}control rendering flow and repeating lists. - Custom PostBrix Helpers: Built-in helpers for comparisons (
eq,gt,lt,contains), formatting (formatCurrency,formatDate), text transform (uppercase,lowercase), and fallbacks (fallback).
Compilation vs. Runtime Hydration#
Understanding when templating happens is key:
- Design Time (PostBrix): Your visual blocks and Handlebars expressions are compiled into clean, responsive MJML and HTML structures. The dynamic tags (like
{{firstName}}) are preserved inside the HTML table cells. - Runtime (Your Server or ESP): When sending an actual email, your server or ESP substitutes the dynamic tags with the recipient's real data before delivery.
ESP Merge Tag Translation Engine
Select your delivery platform to see the required syntax for personalized fields.
Frequently Asked Questions
Does PostBrix validate Handlebars syntax while I edit?
Yes. If you introduce an unclosed block helper or invalid tag name, the editor displays a visual warning and prevents exporting until the syntax is corrected.
Can I use custom Handlebars helpers not listed in PostBrix?
For in-editor preview, PostBrix provides standard comparison, formatting, and fallback helpers. If your backend uses custom helpers, export the template as Dynamic HTML to evaluate them on your own server.