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

Nathan Bubna commented on VELOCITY-680:
---------------------------------------

Defining that macro would make strict mode complain?  Just tried it and it 
seems to work...

I don't think we'll switch the velocimacro.context.localscope default 
unless/until we do a 2.0 version.   Perhaps in 2.0, we'll do away with #set and 
make users always use  #global or #local (#local would be encouraged for most 
cases then).  For now, i think #local is more useful than #global would be.

On a different note, i was thinking about what #local should do/mean outside 
macros, and i thought that perhaps we could change the way #parse is 
implemented a bit so that if #local is used within a #parse'd template, it only 
affects a local context for that template and not the parent template.   Adding 
this local scope option for #parse would be new, but would then make it 
reasonable for #local to be used all over.   This could then encourage people 
to use #local most of the time, so that their templates can always be #parse'd 
without polluting the parent template's context.   This could then perhaps 
smooth out a (theoretical) transition to just having #global and #local in a 
2.0 version.

There would still be tricky questions about how to handle complex references in 
the LHS, of course.

> 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