Dynamic4 min read•Audience: All, Marketers
Default Values & Fallbacks
Ensure your emails never display awkward gaps or broken sentences when customer data is missing.
Key Takeaways
- Missing customer attributes can lead to embarrassing greetings like "Hello , welcome back!".
- Use the PostBrix fallback helper: {{fallback firstName "there"}} to provide clean default text.
- Alternatively, use {{#if}} conditionals to render distinct sentences when data is absent.
The fallback Helper#
PostBrix includes a built-in fallback helper for Handlebars:
code
handlebars
- If
firstNameis"Sam", output: Hello Sam, - If
firstNameis""orundefined, output: Hello Friend,
You can also use this for account numbers, discounts, and expiration dates:
code
handlebars
Conditional Sentence Fallbacks#
When a simple word substitution feels unnatural, use an {{#if}} block to provide distinct copy variations:
code
handlebars
This guarantees natural grammar regardless of whether customer attributes are populated.
Frequently Asked Questions
Does the fallback helper support numbers?
Yes. You can write {{fallback pointsBalance 0}} or {{fallback discountPercent 10}} to supply numerical defaults.
What happens if a field contains an empty string ("")?
The fallback helper treats empty strings as falsy, immediately returning the specified default fallback value.