Apache Velocity foreach loop #continue

11,434

Solution 1

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.

Solution 2

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.

Share:
11,434

Related videos on Youtube

Premier
Author by

Premier

Updated on June 04, 2022

Comments

  • Premier
    Premier almost 2 years

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

  • Scott
    Scott over 12 years
    Correct. Velocity is a simple template engine, not a full scripting language.
  • Premier
    Premier over 12 years
    Problem was i've a lot of #if, so like in switch-case construct, i wanto to skip to end after the first match.
  • rlegendi
    rlegendi over 10 years
    @NathanBubna Ok, but it has break for example.
  • Scott
    Scott over 10 years
    Having #break doesn't make it a full scripting language where you can expect all the standard features. Velocity is extensible, though, so you can make your own #continue directive. It's also open source, so you can lobby to have your #continue added by default.