Evan Carroll wrote:
> Either way, META variables can't hold arrays
No, but they can hold strings that can be easily split into lists...
> so whats a good solution to accomplish this?
I usually start by creating a 'page' data structure in a pre-processed
template. This copies any static META items from the template object
and performs any fixing-up required. In this case we use the split()
vmethod to turn the css string into a list or provide an empty list as
a default.
e.g. site/config:
[% page = {
name = template.name
title = template.title or template.name
css = template.css.split('\s+') or [ ]
}
%]
You can then define a META item in a template like so:
example.html:
[% META title = 'An example page'
css = 'one.css two.css three.css'
%]
The site/config template splits the META css string into a list of the
three CSS files, and stores it in page.css
If you want to add further CSS files dynamically from the page template
then you just need to push them onto page.css
[% page.css.push('four.css') %]
Then in your wrapper template where you generate the HTML headers, you write:
[% FOREACH css IN page.css %]
<link rel="stylesheet" type="text/css" href="/css/[% css %]">
[% END %]
The technique works equally well for all sorts of things you might want
to add to the HTML headers: CSS files, Javascript files, keywords,
descriptions, etc.
HTH
A
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates