Logic5 min read•Audience: All, Marketers, Developers
Conditional Content (if / unless)
Show or hide entire sections, banners, or paragraphs based on customer segmentation or order properties.
Key Takeaways
- Use the Logic Condition block or {{#if condition}} to conditionally render content.
- Truthy/falsy evaluation: false, null, undefined, 0, and empty arrays hide the block.
- Use {{#unless condition}} for inverse logic (show only when condition is falsy).
- Nest complete sections or individual text blocks inside conditional wrappers.
The Visual Logic Condition Block#
In PostBrix, you can insert conditions visually:
- Open the Left Panel and scroll to Dynamic Logic.
- Drag a Condition block onto the canvas.
- In the right panel, set the Condition Property (e.g.
isVipMember). - Drop any regular content blocks (like a special 20% discount coupon) inside the condition container.
When compiled to MJML, PostBrix automatically wraps the inner markup in Handlebars tags:
code
html
Handlebars Truthy & Falsy Rules#
A condition evaluates to false (hidden) when its value is:
- Boolean
false nullorundefined- The number
0 - An empty string
"" - An empty array
[]
Everything else (including non-empty strings, numbers > 0, and non-empty objects) evaluates to true (visible).
Frequently Asked Questions
Can I nest conditions inside other conditions?
Yes. You can nest an {{#if subcondition}} block inside an outer {{#if maincondition}} block to build granular multi-tier logic.
How do I write an inverted condition (show only if false)?
Use {{#unless hasSubscribed}}...{{/unless}} or select the "Invert condition (unless)" toggle on the Condition block.