Uploaded image for project: 'Velocity'
  1. Velocity
  2. VELOCITY-773

Provide locally scoped #set variables

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Not A Problem
    • 1.7-beta1
    • None
    • Engine
    • None

    Description

      Consider this snippet:
      <!-- Generated pushbutton groups -->
      #foreach ($group in $form.pushbuttonGroups)
      <div class="die-button-group" style="#coordinates($group)">

        • *##foreach ($groupChild in $group.children)
        • *##if (!$velocityHasNext)#set($turnPaddingOff = 'style="padding-bottom: 0px;"')#end
        • *##if ($groupChild.class.simpleName == "Pushbutton")
        • *#<div $!turnPaddingOff>
        • *#<button type="submit" name="$groupChild.name" value="$groupChild.value" onclick="loadSubsequent()">#label($groupChild.label)</button>
        • *#</div>
        • *##end
        • *##end
          </div>
          #end

      There is an inherent bug. After the first run of the outer foreach, the var turnPaddingOff is still available and will always set in the div tag. There is only one workaround. At the end of the outer foreach you have to set it to ''.

      #set should be available as a locally scoped thing in #foreach or other constructs.

      Attachments

        Activity

          People

            Unassigned Unassigned
            michael-o Michael Osipov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: