velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Revusky <>
Subject Re: Macros with large input on parameters
Date Fri, 16 May 2003 19:54:55 GMT
Nathan Bubna wrote:
> Jeremy said:
>>I am curious if it is possible to have macros with large input. I'll
> give a
>>simple example:
>>#macro (block $title $body)
>><table class="Block">
>><tr><td class="BlockTitle">$title</td></tr>
>><tr><td class="BlockContents">$body</td></tr>
> ...
>>In the $body parameter, I would like to be able to run #foreach ...
> #end's,
>>have tables inside of it, etc...
> ...
>>Is their a way to accomplish this?
> and a really quick search of the archives reveals...
> b

Yeah, I think such a search reveals that Velocity doesn't have the 
feature the person is requesting. You cannot associate a nested block 
with a velocity macro. I think that's the feature the poster wants. 
Like, in FreeMarker, you could define the macro "thrice" like so:

<#macro thrice>

and then you could invoke it:

    blah blah

and that would output:

    blah blah
    blah blah
    blah blah

But the blah blah within the invocation could contain any arbitrary 
template text, including variable insertions, loops, and invocations of 
other macros and so on. And, of course the nested block could be a 
thousand lines long, if necessary. No problem.

I notice that this idea has been floated separately on the Vel list and 
people thought it was interesting. But, as far as I know, it was never 
implemented -- mostly, I think, because of the lack of an active 
developer community.

The only solution that comes to mind is to use a template engine that 
has the feature -- like,... ahem, FreeMarker. Here's the manual section 
that explains how this works:

It could be of interest if someone wants to implement this idea.

Best Regards and Greetings from the Dark Side,

Jonathan Revusky
lead developer, FreeMarker project,

> Nathan Bubna

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message