[
https://issues.apache.org/jira/browse/VELOCITY-711?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12679616#action_12679616
]
Nathan Bubna commented on VELOCITY-711:
---------------------------------------
Yeah, the scoping i just implemented is optional and must be explicitly used to
be in play. And when it is used, there are no visibility restrictions, only
lifespan ones. The injected scope objects are added and removed from the
global context at the start and end of their lifetime. So yeah, they are
always visible to inner contained scopes, either directly (if the scopes are of
different names) or via $<scope>[.parent]+ if you have, for instance, one macro
nested inside another. So, as long as the scope hasn't expired, it is
available.
So, given that, the only thing a #scope directive might have to do is shorten
$macro.parent.foo to $foo, and that sounds just like the much-regretted with()
construct in javascript.
> Add a #scope directive for modifying scope behavior
> ---------------------------------------------------
>
> Key: VELOCITY-711
> URL: https://issues.apache.org/jira/browse/VELOCITY-711
> Project: Velocity
> Issue Type: New Feature
> Components: Engine
> Reporter: Byron Foster
> Fix For: 1.7
>
>
> A propose adding a #scope block directive that would take a context as an
> argument, and all VTL within the #scope block would be executed using the
> given scope. The need for this directive comes up when using block macros.
> For example I may want the $bodyContent of the macro to be executed in the
> outer scope of block macro. Take the following case:
> #for($bank in $banks)
> #...@lineitem() $bank.name #if(!$bank.solvent)<b>Bankrupt</b>#end #end
> #end
> #macro(lineItem)
> #scope($macro.outer)<div class="lineItem">$bodyContent</div>#end
> #end
--
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]