Show or Hide Parts of a Document
A condition wraps part of a wiki and includes it only when something is true. It is the most-used piece of wiki logic: one template, and every submission gets only the clauses that apply to it.
Table of Contents
- The Basic Shape
- What Counts as True
- Comparing Values
- ELSE and ELSEIF
- UNLESS
- Combining Tests
- Counting and Totalling
- Conditions Inside a Loop
- Common Mistakes
The Basic Shape
{IF:condition}
…content that only sometimes appears…
{/IF}Every {IF:…} needs a matching {/IF}. The content between them can be anything – paragraphs, tables, images, other logic.
{IF:has_firearms}
My firearms shall be dealt with in accordance with the Firearms Control Act.
{/IF}Tip: Use the Operators tab in the wiki editor sidebar to insert the correct syntax rather than typing it by hand. It fills in the opening and closing tags together, which prevents the most common error.
What Counts as True
Writing a field name on its own tests whether it has a meaningful answer:
{IF:spouse_name}…{/IF}That is true when the field has a value, and false when it is any of the following:
| Value | Result |
|---|---|
| Empty / never answered | False |
No | False |
0 | False |
Anything else – including Yes | True |
This is why a Yes/No question works directly: {IF:is_married} reads naturally and behaves correctly.
Comparing Values
| Test | Meaning |
|---|---|
{IF:field="value"} | Equals |
{IF:field!="value"} | Does not equal |
{IF:field>5} | Greater than |
{IF:field<5} | Less than |
{IF:field>=5} / {IF:field<=5} | Greater/less than or equal |
Quotes around the value are optional when it is a single word, but they are safer and clearer – always quote text values.
{IF:marital_status="Married in community of property"}
The estate is subject to the joint estate provisions set out below.
{/IF}Numeric comparisons compare as numbers when both sides look numeric, and fall back to text comparison otherwise.
ELSE and ELSEIF
{ELSE} supplies the alternative:
{IF:has_children}
I am survived by the children named below.
{ELSE}
I have no children.
{/IF}{ELSEIF:…} adds more branches. The first matching branch wins and the rest are skipped, so order them from most specific to least.
{IF:estate_value>3500000}
Estate duty is likely to be payable.
{ELSEIF:estate_value>0}
The estate falls below the current abatement.
{ELSE}
No estate value was provided.
{/IF}A chain still closes with a single {/IF}, no matter how many {ELSEIF} branches it has.
UNLESS
{UNLESS:…} is the inverse of {IF:…} – include the content when the condition is false. It closes with {/UNLESS}.
{UNLESS:has_children}
I have made no provision for children in this will.
{/UNLESS}Use whichever reads better in plain English. {UNLESS:x} and {IF:x}…{ELSE} can express the same thing; pick the one a colleague would understand at a glance.
Combining Tests
Join conditions with AND and OR (&& and || also work):
{IF:is_married AND has_children}…{/IF}
{IF:province="Gauteng" OR province="Western Cape"}…{/IF}AND binds more tightly than OR, exactly as in arithmetic. When you want the other order, use brackets:
{IF:(a="" OR a="No") AND b="Yes"}…{/IF}Brackets nest to any depth.
Note: Boolean words are only for conditions in the wiki body. Inside a calculated field formula the same logic is written as functions –AND(a, b),OR(a, b),NOT(a). See Calculated Fields in Wikis.
Counting and Totalling
Conditions can count rows in a list or total a column, without a calculated field:
{IF:COUNT(beneficiaries)>1}
My estate shall be divided between the beneficiaries listed below.
{/IF}
{IF:SUM(beneficiaries.percentage)!=100}
NOTE TO DRAFTER: the percentages do not total 100.
{/IF}Blank rows are ignored by the count – a user who added a row and left it empty does not turn a one-beneficiary will into a two-beneficiary one.
Conditions Inside a Loop
Inside {EACH:…}, a condition can test the current row by putting a dot in front of the column name:
{EACH:beneficiaries}
{IF:.relationship="Spouse"}my spouse {ELSE}my {.relationship} {/IF}{.full_name}
{/EACH}The dot means "this row". Without it, the condition looks for a top-level form field of that name and quietly finds nothing. See Repeating a Section for Every Row.
Common Mistakes
| Symptom | Usual cause |
|---|---|
| The whole condition appears as text in the PDF | A missing {/IF}, or a typo in the tag. Every opener needs its closer. |
| The branch never fires | The field name does not match the form exactly, or a row reference is missing its leading dot inside a loop. |
| Both branches appear | Two {IF} blocks were nested when an {ELSEIF} chain was intended. |
| A blank line where a clause was removed | Usually cleaned up automatically. If one persists, check the removed block was not inside a table cell or a styled paragraph of its own. |
| Comparing a number does not work | The value may have arrived as text with a symbol – R 1 000 or 80%. Use a calculated field with NUMBERVALUE() first. |
Tip: The sidebar checks your template as you type and flags conditions that reference a field the linked form does not have. If a branch is not firing, look there first – it usually names the problem.
Next: Repeating a Section for Every Row, or back to Wiki Logic.