velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Will Glass-Husain" <wgl...@forio.com>
Subject Re: Remove last comma...
Date Mon, 17 Jan 2005 18:54:59 GMT
Then you need an if statement to ensure the list has at least 2 elements.

WILL

----- Original Message ----- 
From: "Wiebe de Jong" <wiebedj@shaw.ca>
To: "'Velocity Users List'" <velocity-user@jakarta.apache.org>
Sent: Monday, January 17, 2005 10:04 AM
Subject: RE: Remove last comma...


> How about process the fist line separately, then all the rest.
>
> $1
> #foreach ($i in [2..10],$i#end
>
> Will product 1,2,3..10
>
> Wiebe de Jong
>
> -----Original Message-----
> From: Dimitrios Kolovos [mailto:dskolovos@hotmail.com]
> Sent: Friday, January 14, 2005 2:18 AM
> To: Velocity Users List
> Subject: Remove last comma...
>
> Hi all,
>
> When iterating a collection/array it is usual that you add something after
> each iteration except for the last.
>
> e.g.
>
> #foreach ($i in [1..10])$i,#end
>
> produces
>
> 1,2,3..10,
>
> The only way I know in which I can omit the last comma is to use
> velocityount. Nevertheless, I think it would be more elegant if there was 
> a
> variable (e.g. $output) in the context that represented the so far 
> produced
> text. Then I could call a method like $output.chop(n) and chop the last n
> characters.
>
> Any thoughts?
>
> Dimitrios Kolovos
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 


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


Mime
View raw message