[prev in list] [next in list] [prev in thread] [next in thread] 

List:       velocity-dev
Subject:    [jira] [Commented] (VELOCITY-808) Proposal to add ability to pass
From:       "Nathan Bubna (JIRA)" <dev () velocity ! apache ! org>
Date:       2011-08-03 17:09:27
Message-ID: 1152557286.5112.1312391367357.JavaMail.tomcat () hel ! zones ! apache ! org
[Download RAW message or body]


    [ https://issues.apache.org/jira/browse/VELOCITY-808?page=com.atlassian.jira.plugi \
n.system.issuetabpanels:comment-tabpanel&focusedCommentId=13078854#comment-13078854 ] \


Nathan Bubna commented on VELOCITY-808:
---------------------------------------

hmm.  that is better, but the $args variable would be global and get stomped in \
recursive or multi-level #parses, which has the potential to cause many headaches.  i \
would suggest that the $args would need to become $template.args (i.e. put into the \
$template scope object) so that it is properly nested/popped/etc.  you should \
probably even override the template.provide.scope.control=false default and \
automatically turn $template on when #parse is invoked with arguments, to ensure that \
the template has access to $template.args.

or, if you want named arguments, you could have #parse only accept a map (e.g. \
#parse('tpl.vm' {'foo':$bar}) ) and then automatically copy those map values to the \
$template scope object's storage to make $template.foo automatically available.

> Proposal to add ability to pass variables to #parse()
> -----------------------------------------------------
> 
> Key: VELOCITY-808
> URL: https://issues.apache.org/jira/browse/VELOCITY-808
> Project: Velocity
> Issue Type: Improvement
> Components: Engine
> Affects Versions: 1.7
> Reporter: Sergiy Kovalchuk
> Labels: parse
> 
> I think it would be very useful to be able to pass variables to #parse(), just like \
> to #macro(): #parse("tpl.vm" $var1 $var2 $var3)
> This would add $var's to a local scope of "tpl.vm".
> Current approach of adding vars to a parent template above pollutes global \
> namespace.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic