Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Velocity foreach loop #continue

Tags:

Is there a #continue command for jump to next iteration in foreach loop?

like image 593
Premier Avatar asked Sep 23 '11 13:09

Premier


People also ask

What is Apache Velocity used for?

Velocity can be used to generate web pages, SQL, PostScript and other output from templates. It can be used either as a standalone utility for generating source code and reports, or as an integrated component of other systems.

What is Velocity .VM file?

Developer file used by Velocity, a Java-based template engine; written using the Velocity Template Language (VTL); contains VTL statements inserted in a normal text document; often used for auto-generating Web source code and class skeletons.

How do you add numbers in Velocity template?

You would typically do something like #set ($oldIndex = $number. toNumber($oldIndex)) if you have the NumberTool present in your context, for instance. And that's it, $oldIndex contains an integer! Please note that the Integer.


2 Answers

I have a bunch of velocity code but I don't think I've ever seen this. I believe you have to use a #foreach and then use and #if to check your skip condition within the loop. The VTL guide doesn't seem have a better approach.

like image 56
Mike K. Avatar answered Sep 22 '22 06:09

Mike K.


Based on the documentation, Apache Velocity does not appear to have a #continue function for its foreach loop.

In case it might help, it does have a foreach break directive, added in 2008.

like image 33
Woodchuck Avatar answered Sep 21 '22 06:09

Woodchuck