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

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

<quote>
Defining that macro would make strict mode complain? Just tried it and it seems 
to work...
</qoute>

What did you try?  if I do "#macro( foo )#set( $map.foo = 'bar' 
)$map.foo#end#foo()" it will throw an exception

<qoute>
I don't think we'll switch the velocimacro.context.localscope default 
unless/until we do a 2.0 version.
</qoute>

Agreed

<qoute>
For now, i think #local is more useful than #global would be. 
</qoute>

If you're not using the local scope setting.  However I would argue that 
#global is much more useful to the local scope setting then #local is to not 
using the local scope setting.  While when not using local scope settings the 
developer may be in danger of possible side effects, but they can alway just 
use very unique variable names to insure they are not altering a global values. 
 However, if using local scope settings, there is no way to set global values.

I think with a #global directive the local scope setting becomes the more 
appropriate choice.

If Jarkko implements the #local directive I'll do a shameless copy and 
implement the #global version of it.



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