RFC: new directive: #call
-------------------------
Key: VELOCITY-666
URL: https://issues.apache.org/jira/browse/VELOCITY-666
Project: Velocity
Issue Type: Improvement
Affects Versions: 1.6.2, 1.7
Reporter: Jarkko Viinamäki
Inspired by VELOCITY-583 (BlockMacro support) I implemented the same
functionality in a slightly different way.
This patch introduces a new directive #call("mymacro" $arg1 $arg2 ... ) any
valid Velocity content here #end
This directive causes a call to defined macro with given arguments AND passes
the enclosed AST as an argument which can be referenced with $bodyContent
(default, name is configurable).
An example:
#set($foobar = "yeah!")
#macro(strong $txt)
<strong>$bodyContent</strong> $txt
#end
#call("strong" $foobar)
<u>This text is underlined and bold</u>
#end
Will print:
<strong><u>This text is underlined and bold<u></strong> yeah!
Like I commented in VELOCITY-583 the same thing can be done by first using
#define to build up some custom AST and then pass that AST as an argument to
some macro. While it works, it's not as convenient as this syntax. This patch
however increases the amount of code lines in Velocity and the implementation
is a bit "hackish" so even I'm not totally convinced whether we should commit
this.
But anyway, here it is, I'd love to hear your comments.
--
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]