velocity-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nathan Bubna (JIRA)" <>
Subject [jira] Commented: (VELOCITY-680) RFC: New #local directive that behaves like #set but puts things into local context in macro rendering
Date Wed, 18 Feb 2009 18:44:02 GMT


Nathan Bubna commented on VELOCITY-680:

Continuing my broad tirade about VTL simplicity, i'd like to address this as well.

Basically, i don't want more directives for #setlocal and #setglobal support.  To my eyes,
it's inflexible, non-extensible clutter, especially if we keep around config options like
velocimacro.context.localscope to complicate the possibilities.

Ideally, i would love to get rid of all such configuration options and extra directives and
just improve #set to allow the scope to be specified in a very VTL-specific and extensible
manner (akin to my suggestion for VELOCITY-703):

#set( $foo = 'bar' ) ## if foo is undefined, set it in the most local scope.  if foo is defined
already, set it in the scope it came from
#set[parse]( $foo = 'bar' ) ## sets foo in the current #parse scope
#set[macro]( $foo = 'bar' ) ## sets foo in the current macro's scope
#set[foreach]( $foo = 'bar' ) ## sets foo in the current #foreach scope

Depending on the implementation, this syntax might be extensible and allow VelocityView contexts
to recognize and handle things like:

#set[request]( $foo = 'bar' )
#set[session]( $foo = 'bar' )
#set[application]( $foo = 'bar' )

Again, this keeps the namespace clear, is easy to extend in the future, removes the need for
quasi-useful scope configuration settings, and is explicitly VTL-centric.

I really don't know if i have the parser savvy to follow through on this myself given my current
time limitations, but perhaps this vision will inspire someone to help. :)

> RFC: New #local directive that behaves like #set but puts things into local context in
macro rendering
> ------------------------------------------------------------------------------------------------------
>                 Key: VELOCITY-680
>                 URL:
>             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:
For additional commands, e-mail:

View raw message