[Templates] Extracting Meta Data from Other Templates

[prev] [thread] [next] [Date index for 2004/06/29]

From: Steve Dunn
Subject: [Templates] Extracting Meta Data from Other Templates
Date: 03:04 on 29 Jun 2004
As is normal, I have a template for the content of each page on my site. 
Each of these "article templates" has META data such at an ArticleTitle. I 
would like to be able to build site maps and "section maps" which use these 
data but I would like to be able to continue to keep META data for an 
article, such as the title, in the same file as the content for 
maintainability purposes.  i.e. I do not want to put all the article titles 
in some big hash in a global file. So what I would like is any template, 
very possibly another article template, to be able to access the META data 
in any article template in the site.

I have figured out a way, but it is rather byzantine by my lights. 
Basically to extract meta data from a template, you PROCESS the template, 
but with a special flag set. Each article template is responsible for 
reading the flag, and if it is set, instead of generating a page as usual, 
it sets global variables with the contents of the template's META items. 
Every article template has the same META items.

I came up with two MACROs to automate this and make it maintainable. I have 
to add one line to each article template to invoke a macro which embodies 
the conditional processing to expose the META data. I execute a second 
macro from the other template with name of the template I want to get the 
META data out of as a parameter, and then the META data is found in global 
variables. If there is a new standard META item I only have to add a line 
to my macro to expose it on demand.

Anyway, I am wondering if there is some obvious simple way to do this 
that's better than what I've done. Thanks in advance for any advice.

                             =Steve Dunn=




The possibilities are infinitely  | CancerGuide: http://cancerguide.org
greater than the averages.        | "When you need the right questions"



_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates

[Templates] Extracting Meta Data from Other Templates
Steve Dunn 03:04 on 29 Jun 2004

Generated at 08:56 on 15 Mar 2005 by mariachi v0.52