velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jon Stevens <>
Subject Re: Dynamic macro names?
Date Wed, 05 Sep 2001 03:18:44 GMT
on 9/4/01 6:43 PM, "Mark de Reeper" <> wrote:

> Is it possible to call a macro where part/all of the name is dynamic?

I doubt it. Did you try it?

> e.g.
>   #set( $themename = "default" )
>   #${themename}header()
> I do not expect it to work based on what I read in the documentation.
> Maybe there is a better way to achieve what this is trying to do...
> I want to define a bunch of web themes, i.e. table headers/footers etc
> that can be referenced as macros. This allows me to have them all
> loaded at startup of Velocity and available to all templates. The
> macro's therefor need unique names.
> I want to be able to switch to different themes, based on it's name.
> The nice thing about having the theme elements as macro's is that I can
> keep them in a template file rather than stored away in some properties
> file, which makes it easier for a HTML type person to create them.
> Having them as macro's also means that each theme macro can refer to
> existing context elements.

You really should consider using a framework like Turbine which allows you
to define Layouts and Navigations (ie: headers/footers/pieces of foo). Doing
this with macro's is not a good idea.


View raw message