A template often needs to say different things depending on the data filling it in — show a late-payment notice if the balance is overdue, swap a pricing block based on the customer’s plan, hide a disclaimer when the signer is over 18. MakeBox expresses all of this with one mechanism: a conditional block wrapping one or two conditional branches.
The block and its branches
The block itself is a thin wrapper — it carries the condition and a hasElse flag, but no visible content. Its direct children are branches: an if branch that renders when the condition evaluates true, and optionally an else branch that renders when it evaluates false. If there’s no else and the condition is false, nothing renders — the block collapses.
Branches can hold anything a page can — paragraphs, tables, images, nested conditional blocks, variable chips, signatures. The block is layout-neutral, so the chosen branch flows into the surrounding content as if nothing special had happened.
The shape of a condition
Every conditional block owns one condition, built from three things:
| Part | What it is | Example |
|---|---|---|
| Path | Which variable to check — a dotted path into the template’s schema | customer.plan, order.total, signer.age |
| Operator | How to compare — equals, not equals, greater than, contains, is empty, is not empty, and so on | equals |
| Value | What to compare against, typed to match the field | "premium", 100, true |
A condition like “show the welcome block when the customer’s plan equals premium” reads as path customer.plan, operator equals, value "premium". The value’s type (string, number, boolean) is tracked alongside it so comparisons behave sensibly — 100 as a number doesn’t accidentally match "100" as a string.
Operators that take no value (is empty, is not empty) omit the value side entirely.
When it fires
The block doesn’t evaluate itself. The surrounding surface — the editor’s preview mode, the form-fill surface, the PDF renderer — looks at the condition each time it runs:
- In the editor, sample data drives it. A condition reading
customer.plan equals premiumevaluates against whatever thecustomer.plansample value is at the moment. Toggle the sample and the branch flips live. - On a filled form, the submitter’s answers drive it. The same condition fires as they type or make a selection, so a field in the
elsebranch can appear mid-fill. - In the final PDF, the submitted data drives it. Exactly one branch is baked into the printed output.
A condition whose path points at a field the data doesn’t contain reads as empty — is empty is true, every other operator is false, so the default behaviour is “hide.” There’s no error; the template keeps rendering.
What it is NOT
Three mechanisms get called “conditional” in casual conversation. Only one of them is this feature.
| Mechanism | What it does | Where it lives |
|---|---|---|
| Conditional block (this page) | Shows one branch, hides the other, based on a condition | In the editor content, around any content |
| Cascade | Filters a child form field’s options based on the parent field’s value | On a form field’s cascadeDataSource / cascadeLevels |
| Composite section | Always emitted — a Composite’s sections are an ordered list, not a conditional one | On a Composite |
Cascade is sibling behaviour between form fields — a country field narrows the state dropdown, a product field narrows the SKU dropdown. The form-field options change, but every field still renders. See How cascading form fields work.
Composite sections are always-on. A Composite is an ordered list of sections (templates, table-of-contents slots, glue content), and every one of them is emitted on every render. If you need to leave a section out based on a condition, do it inside the section’s template with a conditional block — the Composite itself doesn’t have a conditional-section slot.
In Composites
A Composite is an ordered list of sections. Every section is emitted on every render — there’s no “conditional section” slot that skips one based on a condition. That absence is intentional; the mechanism for “sometimes show this section, sometimes don’t” lives one level down, inside the section’s content.
How to hide a section conditionally. Open the template that fills the section. At the very top of that template’s content, drop a conditional block whose if branch holds the section body and whose else branch is empty (or an alternative). When the condition evaluates false, the branch collapses and the section renders as empty — effectively hidden.
Why it’s structured this way. Section ordering is a page-layout decision (which slot goes where on the printed page, where the TOC lands, where the glue prose bridges two templates). Content presence is a data-driven decision. Keeping them on separate layers means a jurisdictional clause in a master agreement always occupies “slot 4” visually, but what prints in that slot — US language, EU language, or nothing — is decided by data at render time without rearranging the Composite.
A worked example. A master service agreement with four sections: cover, master terms, jurisdictional clause, signatures. The jurisdictional clause section is always present. Inside its template, the top-level block is a conditional block on customer.jurisdiction:
equals "US"→ the US clause bodyelsebranch → a nested conditional block oncustomer.jurisdiction equals "EU"→ the EU clause, else empty
Three possible outputs, one Composite, one section slot. See Composite sections for the section model.
Nesting and edge cases
- Nesting works. An
ifbranch can contain another conditional block. The inner block’s condition is evaluated whichever branch wins at the outer level — the outerelsenever fires its contents, so an inner block inside it never fires either. - The block is skippable in serialisation. Because the wrapper is layout-neutral, it doesn’t participate in margin collapse or table rows — it just hands rendering off to the winning branch.
- Variable chips inside a branch bind the same way they do anywhere else. Nothing about living inside an
iforelsechanges how a chip resolves at render time; see How variables bind to content.
See also
- How variables bind to content — what the condition’s path points at
- How cascading form fields work — the cousin that looks similar but isn’t