Return-Path: Delivered-To: apmail-jakarta-velocity-user-archive@jakarta.apache.org Received: (qmail 85045 invoked by uid 500); 5 Sep 2001 03:18:39 -0000 Mailing-List: contact velocity-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Reply-To: velocity-user@jakarta.apache.org Delivered-To: mailing list velocity-user@jakarta.apache.org Received: (qmail 85036 invoked from network); 5 Sep 2001 03:18:39 -0000 User-Agent: Microsoft-Entourage/9.0.1.3108 Date: Tue, 04 Sep 2001 20:18:44 -0700 Subject: Re: Dynamic macro names? From: Jon Stevens To: velocity-user Message-ID: In-Reply-To: <20010905014351.69547.qmail@web10003.mail.yahoo.com> Mime-version: 1.0 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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. -jon