velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christoph.R...@dlr.de
Subject Re: Is there a way to tell when iterating in #foreach if you have com e to the last element.
Date Mon, 09 Sep 2002 12:23:07 GMT
To avoid depending on how the $velocityCount is configured, I prefer to
use the implicit form:
#set( $sep = '' )
#foreach($o in $list)$sep$o#set( $sep = '.' )#end

-- 
:) Christoph Reck

Cort Schaefer wrote:
 > In the case that you proposed, you could also base it on whether you are on
 > the first element or not, ie:
 >
 > #foreach($o in $list)#if($velocityCount>1).#end$o#end
 >
 >

Geir Magnusson Jr. wrote:
> On 9/6/02 12:12 PM, "Joshua.Levy@reasoning.com" <Joshua.Levy@reasoning.com>
> wrote:
> 
> 
>>>Maybe the velocity team can plug in a
>>>$hasNext = true|false
>>>as it already maintains a loop $velocityCount variable.
>>
>>If you do this, then I vote for $velocityHasNext or something
>>else which minimizes the namespace confusion.  With velocity,
>>you are already dealing with the Java namespace, and the
>>velocity macro/variable namespace.  It would be nice if all
>>the velocity created variables had related names.
>>
> 
> 
> The string 'velocityCount' is actually configurable.  I'm not sure that in
> itself was a good thing, but it does give you the freedom to change it.  The
> downside, of course, is that if you do change it for your template, it will
> be unreadable for people who don't know you are changing the loop var name
> behind the scenes.
> 

-- 
:) Christoph Reck


--
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