Return-Path: Delivered-To: apmail-velocity-dev-archive@www.apache.org Received: (qmail 833 invoked from network); 18 Feb 2009 19:24:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Feb 2009 19:24:27 -0000 Received: (qmail 60231 invoked by uid 500); 18 Feb 2009 19:24:26 -0000 Delivered-To: apmail-velocity-dev-archive@velocity.apache.org Received: (qmail 60222 invoked by uid 500); 18 Feb 2009 19:24:26 -0000 Mailing-List: contact dev-help@velocity.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Velocity Developers List" Delivered-To: mailing list dev@velocity.apache.org Received: (qmail 60183 invoked by uid 500); 18 Feb 2009 19:24:26 -0000 Delivered-To: apmail-jakarta-velocity-dev@jakarta.apache.org Received: (qmail 60178 invoked by uid 99); 18 Feb 2009 19:24:26 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Feb 2009 11:24:26 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Feb 2009 19:24:23 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 348F4234C4AD for ; Wed, 18 Feb 2009 11:24:02 -0800 (PST) Message-ID: <1656623011.1234985042213.JavaMail.jira@brutus> Date: Wed, 18 Feb 2009 11:24:02 -0800 (PST) From: "Claude Brisson (JIRA)" To: velocity-dev@jakarta.apache.org Subject: [jira] Commented: (VELOCITY-680) RFC: New #local directive that behaves like #set but puts things into local context in macro rendering In-Reply-To: <956559525.1232648039895.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/VELOCITY-680?page=3Dcom.atlassi= an.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D12= 674753#action_12674753 ]=20 Claude Brisson commented on VELOCITY-680: ----------------------------------------- > Basically, i don't want more directives for #setlocal and #setglobal supp= ort. To my eyes, it's inflexible, non-extensible clutter, especially if we = keep around config options like velocimacro.context.localscope to complicat= e the possibilities.=20 I agree - if we find a nice way of specifying the context in #set, it's bet= ter than multiplying the number of directives. But why not just specify the scope as a second optional argument to #set, a= s in : #set( $foo =3D $bar, parse )=20 Visually complex syntaxes can really scare people coming from the world of = the web design - brackets followed by parenthesis are really confusing. > Depending on the implementation, this syntax might be extensible and allo= w VelocityView contexts to recognize and handle things like: > #set[request]( $foo =3D 'bar' ) > #set[session]( $foo =3D 'bar' ) > #set[application]( $foo =3D 'bar' ) Those ones already have a very natural syntax (which I didn't include in th= e trunk to avoid having the tools depending on a too recent version of the = engine - but, by the way, it's enough not to configure its use by default, = so I'll include it!): #set($request.foo =3D 'bar') #set($session.foo =3D 'bar' ) #set($application.foo =3D 'bar' ) Since $request, $session and $application all are legitimate objects, I don= 't think we need something else. Ah. Speaking of this, I think of another solution about the scoped syntax d= ebate, which in fact is the one I like the most now that I think of it: the= tools approach. Why not give each scope an object representing it, that is a $foreach, a $t= emplate and a $macro? It looks like really very customizable (as users can = inherit hose objects) and flexible. That would give things like: #foreach($i in $collection) #set($foreach.foo =3D 'bar') #if($i =3D=3D 'I want to break out') $foreach.break() #end #if( $i =3D=3D 'red alert' ) $template.stop() #end #macro(mymacro) #set($mymacro.mylocal =3D 'bar') #end etc... > RFC: New #local directive that behaves like #set but puts things into loc= al 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=C3=A4ki > Attachments: velocity-local-directive-1.1.patch, velocity-local-d= irective.patch > > > It would be very useful to be able to set variables that are in local mac= ro scope. That is, they do not overwrite "global" variables and are thrown = away after macro rendering. This would allow people to build macro librarie= s that do not clash so easily with each other. > There is some implementation of a "LocalDirective" in experimental/locald= irective 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 implementatio= n 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 pat= ch. --=20 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: dev-unsubscribe@velocity.apache.org For additional commands, e-mail: dev-help@velocity.apache.org