Master workflow logic using if/else, for loops, and case statements to handle different scenarios.
==
(equals)!=
(does not equal)>
(greater than)<
(less than)>=
(greater than or equal to)<=
(less than or equal to)and
(logical AND)or
(logical OR)contains
(checks for a substring in a string, or a value in an array)unless
is the opposite of if
. It executes a block of code only if a condition is not met.
case
tag creates a switch statement to compare a variable against a series of values. It’s a cleaner way to write a long chain of elsif
statements.
for
tag lets you loop through each item in an array (a list). This is incredibly useful for creating reports or formatted lists.
for
loop, you have access to special variables to get information about the loop’s progress:
forloop.index
: The current iteration of the loop (1-based).forloop.first
: Returns true
if it’s the first iteration.forloop.last
: Returns true
if it’s the last iteration.forloop.length
: The total number of items in the array.{% else %}
block inside a for
loop that will only be executed if the array is empty.