If (Conditionals)
Conditional fields allow you to show or hide sections of your template based on data values. Use them to create dynamic documents that adapt to each client's situation.
Basic syntax
Use {{#if}} to conditionally render a block. The block renders if the field is truthy (not null, not empty, not false, not zero).
Basic conditional
{{#if has_insurance}}
Your current insurance arrangements are summarised below.
{{/if}}If/else
Use {{else}} to provide fallback content when the condition is false.
If/else
{{#if has_spouse}}
This advice covers both {{client_name}} and {{spouse_name}}.
{{else}}
This advice is prepared for {{client_name}}.
{{/if}}Comparison operators
You can compare field values using operators for more precise conditions.
Comparison syntax
{{#if risk_score gt 7}}
Based on your high risk tolerance, we recommend a growth-oriented strategy.
{{/if}}
{{#if age gte 65}}
As you are at or approaching retirement age, we have focused on capital preservation.
{{/if}}
{{#if risk_profile eq "Conservative"}}
Your conservative profile means we prioritise stability over growth.
{{/if}}- eq — equals
- neq — not equals
- gt — greater than
- gte — greater than or equal to
- lt — less than
- lte — less than or equal to
Combining with loops
Conditionals work inside loops. For example, you can conditionally style certain rows in a table based on a property of each item.
Whitespace
Conditional blocks may leave blank lines in your document if the condition is false. Use inline conditionals or trim whitespace in your template to avoid unwanted gaps.