#foreach already has $velocityCount.  Add $isFirst and $isLast.  Simple to
write a macro for this...
Just add (somewhere)
#set ($isLast = $velocityCount.equals( $arg3.size() ) )
#set ($isFirst = $velocityCount.equals( 1 ) )

#foreach ($obj in $List)
   #if ($isFirst) <table> #end
    <tr><td>$obj.Attribute</td></tr>
   #if ($isLast) </table> #end
#end

to the foreach definition.

Note that there is a problem with global variables like these (including
velocityCount) when loops are nested, and there is no obvious solution.
Maybe allow a kludgy index by the loop variable name...

$velocityCount.of("obj") or $isFirst.for("obj")...

Better would be $obj.count(), $obj.isFirst() but that would require
dynamically generating a specialization of whatever class $obj happens to be
at each assignment (since you want $obj to behave like the kind of object
the designer expects).  Hardly worth the complexity.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to