On Mon, 2 Oct 2000, Geir Magnusson Jr. wrote:
> Below is a (long) proposal for macro capabilities for Velocity. I have
> attached code that works with the current CVS tree. Please give a read
> through, ask questions if interested and try it if you have the time. I
> am looking for list approval to get this integrated into Velocity.
[snip]
I think it's a great idea. Basically an extension mechanism
for template maintainers, designers. This would be very
easy to integrate once the #foo (args) type syntax is
finished, because the designer then can specify whatever
arguments they may wish.
In terms of how it might look, I was thinking something
like the following might be good.
#macro (greeting $name $today)
#if ($time.isMorning())
#set $time = "morning"
#else
#set $time = "afternoon"
#end
Good $time $name! $today is your lucky day!
#end
then it could be used like pluggable directive:
#greeting ($name $time)
or
#macro (row $content) <tr><td>$content</td></tr> #end
<table>
#foreach ($element in $list)
#row ($element)
#end
</table>
Maybe not a useful examples, and a designer
might not use a lot of logical constructs
but they can make whatever they want. You
don't have to be a programmer to make a
macro and I think it would be amazingly
useful to be able to create macros in
templates. They are basically pluggable
directives created in templates. Or rather
with template code, you could have a global
repository of macros.
Anyway, I think very useful!
jvz.
--
Jason van Zyl
[EMAIL PROTECTED]