[
https://issues.apache.org/jira/browse/VELOCITY-680?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12666253#action_12666253
]
Nathan Bubna commented on VELOCITY-680:
---------------------------------------
Comments, eh? In no particular order, here's my thoughts...
I like this approach better than the old #local, which always felt rather
unwieldy, despite having a much simpler implementation than yours does.
I'm open to adding a directive for this purpose now that macros aren't terrible
performers with no body support. Previously, i didn't personally consider
macros worthy of a new directive just to aid in sharing/re-using them. Things
have improved...
Perhaps if strict ref mode is on when you catch a #local outside of a macro,
you could throw an error then? Hmm, at least the old #local made sense when
used anywhere, not just in a macro, as it created it's own scope block.
In ASTLocalDirective.render(), shouldn't you just check what kind of context it
is within during init, so that we don't have to do that try/catch (or even
check isLocalContextScopeForced) during each render?
If added, we'd have to make this addition very obvious in release notes and
docs so that users using the old #local (or a macro of that name?) will have
sufficient warning. Either that or we could go with another name (#setlocal?),
though i can't think of any name/syntax that i prefer to #local.
> 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]