You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@roller.apache.org by Michael Lamberton <la...@lssaa.wisc.edu> on 2009/06/24 17:11:28 UTC

Template Problem (velocityHasNext)

Hi roller user list,
Due to a picky client, I need to have tags separated by commas.  I have 
some code written already, but because of a bug in the velocity engine, 
the $velocityHasNext variable isn't working in a nested foreach loop.  
Is there a way to update the velocity engine in roller with the latest 
version?
Thanks,
Mike


Re: Template Problem (velocityHasNext)

Posted by Anil Gangolli <an...@busybuddha.org>.
Michael Lamberton wrote:
> Hi roller user list,
> Due to a picky client, I need to have tags separated by commas.  I 
> have some code written already, but because of a bug in the velocity 
> engine, the $velocityHasNext variable isn't working in a nested 
> foreach loop.  Is there a way to update the velocity engine in roller 
> with the latest version?
> Thanks,
> Mike

In principle yes, but you might run into compatibility issues and the 
need to upgrade other dependencies if you do that. 

An uglier alternative that might work for you is to get the size of the 
list/collection using $theCollection.size() prior to the loop, store it 
in a variable, and then count and use a conditional within the loop to 
decide whether to place the comma or not.

I think there are some examples of using .size() (though not in this 
way) in the stock macros in weblog.vm if you poke around .

--a.