Velocity
  1. Velocity
  2. VELOCITY-612

Support for #break directive inside foreach loops (includes a patch)

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.6
    • Component/s: Engine
    • Labels:
      None

      Description

      Here's a small patch that adds support for #break directive that can be used to break foreach-loops.

      Catch: #break does not verify that it is inside a foreach loop. If it is not, a RuntimeException of type BreakException is thrown during rendering and not caught properly. Testcases are also quite laughable but the directive seems to work OK.

      1. velocity-1.6-dev-break-directive.patch
        10 kB
        Jarkko Viinamäki
      2. ForeachBreakTestCase.java
        3 kB
        Nathan Bubna

        Issue Links

          Activity

          Hide
          Nathan Bubna added a comment -

          this looks great, Jarkko. i did enhance the test case some (see attached). i'll go ahead and commit this. do you think you could add a patch for documentation that demonstrates using this in #foreach?

          Show
          Nathan Bubna added a comment - this looks great, Jarkko. i did enhance the test case some (see attached). i'll go ahead and commit this. do you think you could add a patch for documentation that demonstrates using this in #foreach?

            People

            • Assignee:
              Unassigned
              Reporter:
              Jarkko Viinamäki
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development