[prev in list] [next in list] [prev in thread] [next in thread]
List: velocity-dev
Subject: [jira] Updated: (VELOCITY-666) Blockmacro support (allows any AST
From: Jarkko_Viinamäki_(JIRA) <dev () velocity ! apache ! org>
Date: 2009-12-16 11:53:20
Message-ID: 1335378247.1260964400205.JavaMail.jira () brutus
[Download RAW message or body]
[ https://issues.apache.org/jira/browse/VELOCITY-666?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel \
]
Jarkko Viinamäki updated VELOCITY-666:
--------------------------------------
Description:
Inspired by VELOCITY-583 (BlockMacro support) I implemented the same functionality in \
a slightly different way.
The new syntax is:
#@yourMacroName($arg1 $arg2) any valid velocity AST here #end
so basically the syntax is exactly the same as for normal macros except you put that \
@ prefix to the macro name. That tells Velocity that there's a macro AST body that \
should be passed to the actual macro.
And in the macro you can refer to the passed body 0-N times. Like:
#macro(yourMacroName $foo $bar)
$bodyContent
#end
was:
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.
Summary: Blockmacro support (allows any AST as macro body argument) (was: \
RFC: new directive: #call)
Modified the issue title and description to reflect better what was actually \
implemented.
> Blockmacro support (allows any AST as macro body argument)
> ----------------------------------------------------------
>
> 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
> Fix For: 1.7
>
> Attachments: velocity-blockmacro.patch, velocity-call-directive.patch
>
>
> Inspired by VELOCITY-583 (BlockMacro support) I implemented the same functionality \
> in a slightly different way. The new syntax is:
> #@yourMacroName($arg1 $arg2) any valid velocity AST here #end
> so basically the syntax is exactly the same as for normal macros except you put \
> that @ prefix to the macro name. That tells Velocity that there's a macro AST body \
> that should be passed to the actual macro. And in the macro you can refer to the \
> passed body 0-N times. Like: #macro(yourMacroName $foo $bar)
> $bodyContent
> #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: 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