You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Bill Kaufman <BK...@zaplet.com> on 2002/10/08 22:28:22 UTC

RE: For() or while() in VTL...

>     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

> Once again, is there a more
> complete VTL Reference?

http://jakarta.apache.org/velocity/user-guide.html
http://jakarta.apache.org/velocity/vtl-reference-guide.html

> Are there libraries for Velocity? Hope so...

http://jakarta.apache.org/builds/jakarta-velocity/

                                                      -- Bill K.

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: For() or while() in VTL...

Posted by Denis <ji...@respublica.fr>.
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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>