[
https://issues.apache.org/jira/browse/VELOCITY-666?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12851044#action_12851044
]
Nathan Bubna commented on VELOCITY-666:
---------------------------------------
Using #blockmacro to define a macro with a body has two major drawbacks for me:
- it divides macros into two classes, which is not at all an insignificant
complication for users, particularly those using macro libraries created by
others. #@ allows the macro writer to make macros with the $bodyContent
optional and gives template readers/users clear indication of how the macro is
being used.
- more significantly, it introduces implementation headaches when parsing a
not-yet-defined macro. See Raghu's 4 options for dealing with this in
VELOCITY-583, of which the favored required a new prefix character for using
the block macro also.
It's a new feature. A little forgetfulness can be forgiven. :)
> 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: [email protected]
For additional commands, e-mail: [email protected]