Loops and lists
Use $each to repeat text for every item in a list. The name after as receives the current item; an optional second name receives its index.
$each(["News", "Chat"] as @item, @index) $(@index + 1). @item$endResult:
1. News2. ChatItems follow list order. Adding one to the zero-based index produces the numbering shown to readers.
Locals within a loop
Section titled “Locals within a loop”Item and index names must differ. They shadow matching outer names without replacing the outer values.
A local first declared in the body is initialized again each iteration. To accumulate a result, declare it before the loop, as shown in local variables.
Iterate over a map
Section titled “Iterate over a map”The first binding receives the value and the second receives the key. The loop visits keys in ordinal text order, regardless of the order in which you wrote them.
$set(@rooms, { music: "Room 2", drawing: "Room 1", art: nil })$each(@rooms as @room, @workshop) $if(!@room) $continue $end $upper(@workshop): @room$endResult:
DRAWING: Room 1MUSIC: Room 2$continue skips the workshop with no room. Use $break to leave the nearest loop, or $stop to finish the current field and keep its output.
Optional data and limits
Section titled “Optional data and limits”Nil runs zero iterations, so an optional list does not need a fabricated replacement. Other scalars are not iterable, and collections cannot be mutated during iteration.
Nested loops share the field’s execution allowance. If you only need comma-separated text, $join is often simpler; see text and number functions.