You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Tiho Lupak <tl...@yahoo.com> on 2008/06/19 15:31:37 UTC
Dynamically adding macros?
Is it possible to dynamically add new macros to a running Velocity instance ?
Or at least new macro names to an existing one?
Right now there's a static macro in macros.vm that does something like this:
----------
#macro( writeList $list)
#foreach($item in $list)
$item
#end
#end
----------
In HTML pages (from the VelocityServlet), users write something like:
---------
.....
#writeList($my_list_one)
.....
#writeList($our_list_two)
......
---------
The HTML pages are however user written code, and the above syntax is always subject to errors.
A proposed change from the users would be to allow to have instead pages like:
----------
.....
#my_list_one
.....
#our_list_two
.....
----------
but "my_list_one" and "our_list_two" are known only at runtime.
Is this possible with Velocity at all?
Thank you very much,
Tilo.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: Dynamically adding macros?
Posted by Nathan Bubna <nb...@gmail.com>.
On Thu, Jun 19, 2008 at 6:31 AM, Tiho Lupak <tl...@yahoo.com> wrote:
> Is it possible to dynamically add new macros to a running Velocity instance ?
> Or at least new macro names to an existing one?
Yes to both questions. You just need to adjust your settings. See
the "Velocimacro" section here:
http://velocity.apache.org/engine/releases/velocity-1.5/developer-guide.html#velocity_configuration_keys_and_values
> Right now there's a static macro in macros.vm that does something like this:
> ----------
> #macro( writeList $list)
> #foreach($item in $list)
> $item
> #end
> #end
> ----------
>
> In HTML pages (from the VelocityServlet), users write something like:
> ---------
> .....
> #writeList($my_list_one)
> .....
> #writeList($our_list_two)
> ......
> ---------
>
> The HTML pages are however user written code, and the above syntax is always subject to errors.
> A proposed change from the users would be to allow to have instead pages like:
> ----------
> .....
> #my_list_one
> .....
> #our_list_two
> .....
> ----------
> but "my_list_one" and "our_list_two" are known only at runtime.
>
> Is this possible with Velocity at all?
>
> Thank you very much,
> Tilo.
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org