Velocity
  1. Velocity
  2. VELOCITY-700

Add #foreach keyword to specify #break level

    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

      if the last argument to to the #foreach directive is a word, then that word serves as a label to indicate the break level for the #break directive. Par exemple:

      #foreach($user in $users outer)
      #foreach($email in $user.emails)
      #if($email.expired)
      #break(outer)
      #end
      #end
      #end

        Activity

        Hide
        Nathan Bubna added a comment -

        -1 no labels. keep VTL simple, please. it's not java, nor should it be. the ease of teaching it and reading it are important to me. FYI, i'm also still considering vetoing the #foreach( $user in $users index $i ) syntax, since i think it is ugly, unclear, and unnecessary. the more i look at it, the more i dislike it. having that syntax in combo with this one would make my eyes water. (please bear with my grumpy bluntness; i like you, i'm just very concerned about syntax choices.)

        if you really feel it is necessary to control the break level, there is always the LoopTool in velocity tools. yes, that's not that pretty either, but that is part of the point of VelocityTools. keep ugly, but sometimes desirable features out of the core.

        if you really feel it is important to have some better break control in the core, let's discuss other ways. like perhaps an optional integer argument for #break, to indicate how many levels to break out of. Something like that would at least avoid "uglifying" the #foreach syntax, for an unnecessary feature.

        Show
        Nathan Bubna added a comment - -1 no labels. keep VTL simple, please. it's not java, nor should it be. the ease of teaching it and reading it are important to me. FYI, i'm also still considering vetoing the #foreach( $user in $users index $i ) syntax, since i think it is ugly, unclear, and unnecessary. the more i look at it, the more i dislike it. having that syntax in combo with this one would make my eyes water. (please bear with my grumpy bluntness; i like you, i'm just very concerned about syntax choices.) if you really feel it is necessary to control the break level, there is always the LoopTool in velocity tools. yes, that's not that pretty either, but that is part of the point of VelocityTools. keep ugly, but sometimes desirable features out of the core. if you really feel it is important to have some better break control in the core, let's discuss other ways. like perhaps an optional integer argument for #break, to indicate how many levels to break out of. Something like that would at least avoid "uglifying" the #foreach syntax, for an unnecessary feature.
        Hide
        Byron Foster added a comment -

        <qoute>
        FYI, i'm also still considering vetoing the #foreach( $user in $users index $i ) syntax, since i think it is ugly, unclear, and unnecessary. the more i look at it, the more i dislike it. having that syntax in combo with this one would make my eyes water.
        </qoute>

        I get the impression you don't like the 'index' syntax... I of course like it or I would not have implemented it. I think it is superior to the current magic variable approach which I think feels more like an after thought. However, It is a non-issue, I will place the index functionality into the directive.contrib directory.

        Concerning the #break label issue, I don't know how I feel about it, I'm indifferent.. I threw it out there to get some feedback.

        Show
        Byron Foster added a comment - <qoute> FYI, i'm also still considering vetoing the #foreach( $user in $users index $i ) syntax, since i think it is ugly, unclear, and unnecessary. the more i look at it, the more i dislike it. having that syntax in combo with this one would make my eyes water. </qoute> I get the impression you don't like the 'index' syntax... I of course like it or I would not have implemented it. I think it is superior to the current magic variable approach which I think feels more like an after thought. However, It is a non-issue, I will place the index functionality into the directive.contrib directory. Concerning the #break label issue, I don't know how I feel about it, I'm indifferent.. I threw it out there to get some feedback.
        Hide
        Byron Foster added a comment -

        Looks like this is a no-go.

        Show
        Byron Foster added a comment - Looks like this is a no-go.

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development