Conditional rendering allows your template to adapt based on the presence or absence of field values. Mochi uses Mustache-style syntax (<<#field>> … <</field>>) to show or hide parts of your template dynamically.
This makes templates more flexible and avoids displaying empty sections.
Why conditional rendering matters
Conditional rendering lets you:
Hide optional fields that aren’t filled
Show fallback text when fields are empty
Override fields based on priority
Display or hide parts of the template with a checkbox
Build advanced templates without duplication
Basic conditional syntax
Show a section only if a field has a value:
<<#field_name>>
This appears only when `field_name` is filled.
<</field_name>>
Show a section only if a field is empty:
<<^field_name>>
This appears only when `field_name` is empty.
<</field_name>>
Example use cases
Field fallback (override logic)
Suppose a card may include a custom pronunciation override.
If no override exists, fall back to reading: