[
https://issues.apache.org/jira/browse/VELOCITY-680?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jarkko Viinamäki updated VELOCITY-680:
--------------------------------------
Attachment: velocity-local-directive-1.1.patch
Here's a bit revised version of the same thing. I kept the try-catch block
since a) it's simple to implement, b) it doesn't have much performance penalty
and c) I would like to avoid referring to context in init() because basically
nodes should not be dependent on context during init.
I also throw the exception in all cases if #local is used outside macro. Some
strict setting seemed too artificial and it's good to alert the user that he is
not using the directive properly.
I think that if we have this #local directive, velocimacro.context.localscope
becomes more or less useless.
I also think that #set is already equivalent to #global.
Nathan's idea about using #local to set variables only in "parsed" context is
interesting but quite difficult to implement.
Feel free to figure out test cases that break this implementation. Byron is at
least very good at 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-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]