[ 
https://issues.apache.org/jira/browse/VELOCITY-680?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12671002#action_12671002
 ] 

Byron Foster commented on VELOCITY-680:
---------------------------------------

I've added both the #global and #local directive to the 2.0 branch for 
evaluation.  They both are very similar in functionality so I went ahead and 
did them both with the help of Jarkko's contribution.

I'll just say that my strong preference is to simply provide the #global 
directive and default #set to local.  I'm not shooting from the hip on this, it 
seems that this is what the programming word has settled on also.  
Additionally, it seems that some of the original scope considerations where 
leaning in this direction also, such as VELOCITY-61.  So, anyway, that's my 
vote :)

There is one important change with scope behavior.  Before, local scope really 
meant something in the local context was visible from the current macro frame 
down.  Additionally, when setting a variable globally (default #set behavior) 
the variable was actually set in all call frames from the current frame all the 
way up to global (This behavior had special cases depending on what type the 
variable was).

> RFC: New #local directive that behaves like #set but puts things into local 
> context in macro rendering
> ------------------------------------------------------------------------------------------------------
>
>                 Key: VELOCITY-680
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-680
>             Project: Velocity
>          Issue Type: New Feature
>    Affects Versions: 1.7
>            Reporter: Jarkko Viinamäki
>         Attachments: velocity-local-directive-1.1.patch, 
> velocity-local-directive.patch
>
>
> It would be very useful to be able to set variables that are in local macro 
> scope. That is, they do not overwrite "global" variables and are thrown away 
> after macro rendering. This would allow people to build macro libraries that 
> do not clash so easily with each other.
> There is some implementation of a "LocalDirective" in 
> experimental/localdirective but I didn't quite get it and it doesn't follow 
> the same syntax as #set. I used a few minutes to hack together this 
> alternative implementation which behaves exactly like #set but it puts things 
> in local context only.
> There's only one test case since this is Request-for-Comments type of patch.

-- 
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