[ 
https://issues.apache.org/jira/browse/VELOCITY-773?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Nathan Bubna resolved VELOCITY-773.
-----------------------------------

    Resolution: Not A Problem

No.    This is by design.  There are no more implicit scopes in Velocity 1.7+  
All variables are now global scoped by default.   Scoping is now done 
explicitly.  You can turn on the explicit scopes you want/need as listed here:

http://velocity.apache.org/engine/devel/developer-guide.html#Velocity_Configuration_Keys_and_Values

Then use them explicitly:

#set( $macro.foo = 'bar'  )## will vanish when macro is done rendering

> Provide locally scoped #set variables
> -------------------------------------
>
>                 Key: VELOCITY-773
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-773
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>    Affects Versions: 1.7-beta1
>            Reporter: Michael Osipov
>
> 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.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to