If Else
If else blocks are used for conditional rendering of simple values based on current variables.
Syntax
Syntax of if else blocks is almost identical to other conditional blocks.
[#if (<condition>)] <content> [/if]- basic if block structure(@variable == 2)- condition which must be fulfilled in order for the content to be rendered
::: @fear is 3
[#if (@fear == 3)] Your instinct forces you to hide under the table. [/if]
::: blocks can be placed on separate lines for better readability
[#if (@fear <= 2)]
Skin on your arms stars to tingle.
[/if]
Your instinct forces you to hide under the table.
Content
If else blocks support nested markdown and interpolation.
::: @favorite_food is "onigiri", @sanity is -10
[#if (@sanity < -5)]
There! **Right _there!_** A plate full of {{ @favorite_food }}s!
[/if]
There! Right there! A plate full of onigiris!
[#else] and [#else-if]
To avoid some repetition you can use [#else] and [#else-if] blocks.
::: @courage is 2
[#if (@courage >= 5)]
You take a big swig from the bottle.
[#else-if (@courage >= 2)]
You sniff the contents and then decide to drink from the bottle.
[#else]
You politely decline the offer.
[/if]
You sniff the contents and then decide to drink from the bottle.
See also
- [passage-if] blocks.
- [audio-if] blocks.
- [block-if] blocks.