|
Fusebox
|
The second of the two "helper" constructs allows for code repetition, by use of a conditional loop. New in Fusebox 4.1 is the ability to additionally perform a query loop or an index loop. To perform a conditional loop, the loop /loop construct takes an attribute of condition, much like the if construct. The loop element iterates over all the commands inside the loop until the condition is logically false: The developer is responsible for ensuring that the loop's condition becomes false at some point lest an infinite loop occur. To perform a query loop, simply provide the attribute query and pass it the name of a valid query result set. Here's an example of a query loop: And finally, to perform an index loop, pass attributes from, to, step, and index. This works the same way that ColdFusion's cfloop does. Here's an example: New in Fusebox 5.1 (at least when using ColdFusion as your scripting language) is the ability to additionally perform a collection loop or a list loop. To perform a '''collection loop''', the loop /loop construct requires 2 attributes: '''collection''' and '''item'''. Example: To perform a '''list loop''', the loop /loop construct requires 2 attributes: '''list''' and '''index'''. While the delimiter attribute is not handled in the FB 5.1 core files, it should be a fairly simple process for the developer to add this capability. Example: Note that each loop block can contain only Fusebox grammar verbs; it cannot contain any nested if or loop elements. This was done intentionally since the place for complex logic is in a fuse, not in a circuit. |
Add Comment