Dynamic4 min read•Audience: All, Marketers, Developers
Variables & Substitution
Insert personalized customer data, order details, and account numbers using double curly braces.
Key Takeaways
- Insert variables anywhere in Text, Headings, Button labels, and Image URLs using {{variableName}}.
- Variables are automatically sanitized to prevent broken HTML markup.
- Provide fallback values to handle recipients with missing profile attributes.
- Test your variables with sample data in the live preview modal.
How to Insert Variables#
You can type variables directly into any text block or use the floating toolbar:
code
text
When rendered with the payload:
code
json
The resulting email renders:
code
text
HTML Escaping Behavior#
By default, Handlebars HTML-escapes all values inside {{variable}}.
- If
companyNameis"Ben & Jerry's", it safely outputs"Ben & Jerry's". - If you have pre-rendered safe HTML that you need to inject without escaping, use triple curly braces:
{{{trustedHtmlContent}}}.
Best Practices for Variable Hygiene#
To ensure dependable delivery across thousands of recipients:
- Consistent Casing: Stick to camelCase (
userEmail,orderNumber) or snake_case (user_email,order_number) across your data schema. - Sanitize Input: Ensure dates and numerical amounts are formatted cleanly or use PostBrix formatting helpers.
- Always Provide Fallbacks: Anticipate missing fields for new or incomplete user profiles.
Frequently Asked Questions
What happens if a variable is missing from the data payload?
Handlebars safely evaluates missing or undefined variables to an empty string ("") without throwing an error or crashing the rendering engine.
Can I put variables inside button links?
Yes. You can write URLs like https://example.com/orders/{{orderId}} directly into the Button block destination URL field.