$LoopTool is used with the #foreach loops. It wraps a list to let you specify a condition to terminate the loop and reuse the same list in a different loop. The following example shows how to use $LoopTool.
#set( $list = [1..7] )
#set( $others = [3..10] )
#foreach( $item in $loopTool.watch($list).sync($others, 'other') )
$item -> $loopTool.other
#if( $item >= 5 )$loopTool.stop()#end
#end
Output
------
1 -> 3
2 -> 4
3 -> 5
4 -> 6
5 -> 7
TEXT
Wrap a list with the tool.
| Name | Type | Description |
|---|
| Parameter(s) | list | java.util.List | An array or a list instance. |
| Return | - | LoopTool | Return an LoopTool instance. |
Check if the iteration has more elements.
| Name | Type | Description |
|---|
| Return | - | boolean | Return true if there are more elements in the wrapped list. |
Ask for the next element in the list.
| Name | Type | Description |
|---|
| Return | - | java.lang.Object | An element instance. |
Remove the current element from the list.
Reset the wrapper so that it will start over at the beginning of the list.
Put a condition to break off a loop.
Return an object as a string.