velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Diggins <subscri...@red56.co.uk>
Subject Re: for loops break?
Date Tue, 12 Jul 2005 08:51:17 GMT
#stop equaled #break in the given minimal example, but in general it 
woudn't  -

 >>>>Is there a way to do something like that?
 >>>>#foreach( $mycounter in [10..1] )
 >>>>   #if ($mycounter == 5)
 >>>>      break; ?
 >>>>   #end
 >>>>#end
##more velocity could go here after break or bottoming out of loop.

I think the usage desired from #break was like the java break keyword - 
"exit the innermost loop"


>>>From the velocity user's manual
> 
>  #stop - Stops the template engine
> 
>     Format:
> 
>     #stop
> 
>     Usage:
> 
>     This will stop execution of the current template. This is good for
> debugging a template.
> 
> 
> On 7/11/05, Will Glass-Husain <wglass@forio.com> wrote:
> 
>>The #stop directive does work correctly in the nightly builds.  I don't
>>think it's the equivalent of #break though.
>>
>>WILL
>>
>>----- Original Message -----
>>From: "Christoph Reck" <apache@recks.org>
>>To: "Velocity Users List" <velocity-user@jakarta.apache.org>
>>Sent: Monday, July 11, 2005 12:54 AM
>>Subject: Re: for loops break?
>>
>>
>>
>>>Hey Folks,
>>>
>>>you should take a look at the IteratorTool:
>>>
>>>http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocity/tools/generic/IteratorTool.html
>>>
>>>More tools at:
>>>http://jakarta.apache.org/velocity/tools/generic/
>>>
>>>Velocity's approach for most problems was always - use a tool!
>>>
>>>In this case a #break directive seems to be a sensible addition, but
>>>note that the tool approach adds much more functionality than could
>>>be achieved by adding directives. The the urge in velocity is to
>>>keep it simple (KISS)!
>>>
>>>I believe remenbering that the #stop directive was (will be?) to work
>>>As-Expected(tm) in the nichglty builds?
>>>
>>>:) Christoph Reck
>>>
>>>
>>>Jean Francois Chamard wrote:
>>>
>>>>Hi there,
>>>>   been using velocity for a while now. Is there a way to get out of a
>>>>loop?
>>>>Perhaps it has been asked but I found nothing on the subject (guide,
>>>>wiki, ...).
>>>>If there is, sorry about it.
>>>>
>>>>Is there a way to do something like that?
>>>>#foreach( $mycounter in [10..1] )
>>>>   #if ($mycounter == 5)
>>>>      break; ?
>>>>   #end
>>>>#end
>>>>
>>>>I've used velocity 1.4 but i'm now with 1.5 dev.
>>>>Thanks for your answer
>>>>JF
>>>>
>>>>---------------------------------------------------------------------
>>>>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
>>
>>
> 
> 
> ---------------------------------------------------------------------
> 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