Reference6 min read•Audience: All, Developers
Dynamic Syntax & Helpers Reference
Exhaustive technical specification of all Handlebars expressions, comparison operators, and custom formatting helpers supported by PostBrix.
Key Takeaways
- Full catalog of built-in PostBrix Handlebars helpers.
- Comparison operators for numbers, strings, and arrays.
- Date and currency formatters for transactional receipts.
- Safe fallback helper syntax.
Built-In PostBrix Helper Reference#
The PostBrix rendering engine registers the following Handlebars helpers:
1. Comparison Helpers
(eq a b): Evaluates strict equality (a === b).- Example:
{{#if (eq plan "pro")}}Pro Customer{{/if}} (gt a b): Greater than comparison (Number(a) > Number(b)).- Example:
{{#if (gt total 50)}}Free Shipping!{{/if}} (lt a b): Less than comparison (Number(a) < Number(b)).- Example:
{{#if (lt balance 10)}}Low Balance Alert{{/if}} (contains haystack needle): Checks if an array or string contains a value.- Example:
{{#if (contains user.tags "vip")}}VIP Access{{/if}}
2. Formatting Helpers
(formatCurrency value): Formats a number with standard currency symbols.- Example:
{{formatCurrency order.total}}→$49.99 (formatDate dateString locale): Formats an ISO date into a localized date string usingIntl.DateTimeFormat.- Example:
{{formatDate "2026-08-15T12:00:00Z" "en-US"}}→August 15, 2026 (fallback value defaultVal): Returnsvalueif truthy, otherwise outputsdefaultVal.- Example:
{{fallback user.firstName "Valued Customer"}} (uppercase str): Converts string to uppercase.- Example:
{{uppercase order.status}}→SHIPPED (lowercase str): Converts string to lowercase.- Example:
{{lowercase user.email}}
Handlebars Syntax Rules & Escaping#
Understanding delimiters:
- Double Curlys
{{variable}}: HTML-escapes content, replacing&,<,>,", and'with HTML entities. Use for all user-supplied text. - Triple Curlys
{{{rawHtml}}}: Bypasses HTML escaping. Use only for trusted HTML strings generated by your internal services. - Sub-expressions
(...): Allows nesting helper calls inside conditions:{{#if (eq (uppercase status) "PAID")}}.
Frequently Asked Questions
Can I register my own custom helpers in PostBrix?
For in-editor preview, PostBrix provides standard comparison, formatting, and text helpers. For custom server-side helpers, export the template as Dynamic HTML and evaluate them using your own backend Handlebars environment.
What happens if a helper throws a runtime error?
PostBrix wraps helper executions in try/catch blocks, falling back to an empty string to ensure a single helper failure does not crash the entire email render.