Mill (Iterator) Viewtool documentation for the dotCMS Content Management System

DEPRECATED: Use the LoopTool instead.

The mill tool is a convenience tool to use with #foreach loops. It wraps a list to let the designer specify a condition to terminate the loop, and reuse the same list in different loops.

The following example shows how the mill tool is mapped in the toolbox-xml file:

    <tool>
        <key>mill</key>
        <scope>request</scope>
        <class>org.apache.velocity.tools.generic.IteratorTool</class>
    </tool>

Example

This lets you do things like:

 Java
  ----
  context.put("mill", new IteratorTool());


  VTL
  ---

  #set ($list = [1, 2, 3, 5, 8, 13])
  #set ($numbers = $mill.wrap($list))

  #foreach ($item in $numbers)
  #if ($item < 8) $numbers.more()#end
  #end

  $numbers.more()


  Output
  ------

   1 2 3 5 8

Warning: It is not recommended to use hasNext() with this tool as it is used to control the #foreach. Use hasMore() instead.

LoopTool Javadoc: LoopTool