Velocity
  1. Velocity
  2. VELOCITY-699

Add a #return directive for returning from a macro

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.x
    • Fix Version/s: 2.x
    • Component/s: Engine
    • Labels:
      None

      Description

      The #return directive would be used to return from a macro call, for example:

      #macro(foo)
      green
      #return
      eggs and ham
      #end

      would render:

      green

        Activity

        Hide
        Byron Foster added a comment -

        Ok, this is an optional directive now which can be accessed with:

        userdirective = org.apache.velocity.runtime.directive.contrib.Return

        But, unofficial.

        Show
        Byron Foster added a comment - Ok, this is an optional directive now which can be accessed with: userdirective = org.apache.velocity.runtime.directive.contrib.Return But, unofficial.
        Hide
        Byron Foster added a comment - - edited

        Hmm, I didn't expect resistance on this one, and I really didn't expect to be accused of complicating Velocity with it . I'm confused by your implication that return == Java. I proposed it because as a Velocity user I would find it useful.

        Anywho, I created a 'contrib' directory under 'directive', and I threw it in there. To use it a user will need to manually add the directive.

        Show
        Byron Foster added a comment - - edited Hmm, I didn't expect resistance on this one, and I really didn't expect to be accused of complicating Velocity with it . I'm confused by your implication that return == Java. I proposed it because as a Velocity user I would find it useful. Anywho, I created a 'contrib' directory under 'directive', and I threw it in there. To use it a user will need to manually add the directive.
        Hide
        Nathan Bubna added a comment -

        -1 let's keep VTL simple and quick to learn and not turn it into java. no return statements.

        if you really, really feel like it would be useful, i suppose i wouldn't veto enhancing #break to work like this, but even that i won't really like. do not add a directive called #return. macros are not java methods.

        Show
        Nathan Bubna added a comment - -1 let's keep VTL simple and quick to learn and not turn it into java. no return statements. if you really, really feel like it would be useful, i suppose i wouldn't veto enhancing #break to work like this, but even that i won't really like. do not add a directive called #return. macros are not java methods.

          People

          • Assignee:
            Unassigned
            Reporter:
            Byron Foster
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development