.if
This directive allows for the selection of a single branch (or none) by use of a condition. This directive takes two forms:
.if{condition}{branch}
.if{condition}{branch 1}{branch 2}
The two-argument form operates as follows:
- If condition is true, branch is returned
- Otherwise nothing is returned
The three-argument form operates as follows:1
- If condition is true, branch 1 is returned
- Otherwise, branch 2 is returned
Example -- Greetings message
Assuming that the variable !is_morning
contains a value which represents whether the current time is morning, we could tailor the user’s greeting message to the current time.
.echo:
.if{!is_morning}:
Good morning!
::
Hello!
1
This form operates exactly the same as an if-else block common to many programming languages.