velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Denis <j...@respublica.fr>
Subject Re: For() or while() in VTL...
Date Thu, 10 Oct 2002 01:44:25 GMT
Hi Rodrigo,

mardi 8 octobre 2002, à 09:28  pm, Bill Kaufman a écrit :

>>     I need to walk through a List, but I need to step every 2
>> items in the list. Is there a for() or while() in Velocity?
>
> #foreach
>
> If you want to skip every other item, you'd need to do something like,
>
> 	#set( $isOdd = $velocityCount % 2 )
> 	#if( $isOdd )
> 		## ... Your code here
> 	#end
>
You could also use FisherMill, a tool for #foreach...
I didn't figure how to document it propely for addition in the tools 
project, so for now you can find it at:

http://www.chez.com/denisb/java

You could do:

#set ($wrappedlist = $mill.wrap($list))
#foreach ($item in $wrappedlist)
... Value of item is: $wrappedlist.more() ...
$wrappedlist.cont() ##skip one item
#end

-- Denis.

--
To unsubscribe, e-mail:   <mailto:velocity-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:velocity-user-help@jakarta.apache.org>


Mime
View raw message