If statements
If statements allow you to control the flow of templates, conditionally displaying some elements while hiding others. For example, if a variable is "falsy", you can hide entire sections of your website:
If statements start with if
and must always finish with end
.
Expressions
If statements support evaluating large expressions for truthiness, for example:
While it's advisable to write simple if statements and delegate complex logic to views where the Rust compiler can be more helpful, Rwf template language is almost Turing-complete and can be used to write arbitrarily complex templates.
Operator precedence
Templates respect operator precedence, e.g., multiplication is performed before addition, unless parentheses are specified (which are also supported).
Else If
If statements support else if blocks (written as elsif
), evaluating multiple expressions and executing the first one which evaluates to true: