If / Else If / Else
The if
flow evaluates the given expression and executes the body if the expression resulted in true
. Otherwise, the body is ignored. It can be chained with else if
and else
, stopping the execution after the first expression resulting in true
.
If
must always start the condition chain and can be optionally followed by else if
and else
. Else
has to always be the last, and can only be used in the chain.
Syntax
Basic syntax of if
tag is as follows:
When additional conditions are needed, use else if
and / or else
to chain them:
Note that else
doesn't have statement
as it serves as a fallback when everything else fails.
Evaluating the statement
This section is a work in progress. If definition is not yet complete
if
or else if
evaluates to true when one of the following conditions is true:
statement
resulting type isBoolean
and== true
statement
resulting type isInt
and>= 1
statement
resulting type isString
and the string is not empty
Example use case
If
can be used to render structurally different data based on the input values. In this example, a different user menu gets rendered based on whether the user is admin, team member, or a visitor.
Data
Blueprint
Result
Finally, if we change user.type
to admin
, the output will look like the following:
Last updated
Was this helpful?