Bill Moseley wrote:
> Or do I need to pass in a separate "mytemplate" hash?
[...]
> and then in my templates do:
> 
>    [% foo = mytemplate.foo || template.foo %]

My usual approach is to have a pre-process template construct a 'page'
data structure, using the template metadata or any other data you have.

config/page:

    [% page = {
         title  = template.title  or some_other_data.title
         author = template.author or 'Andy Wardley'
         ...etc...
       }
    %]

And then in my templates, I access page.whatever rather than 
template.whatever.  This keeps all your page setup logic in one 
place.  If you later decide to store page metadata in a database,
XML file, or something else, then you only need to hack on the 
config/page file to make things work anew.

You can even overwrite the 'template' item if you don't mind burning
your bridges:

    [% template = {
           ...as above...
       }
    %]

The Badger Book has some more detailed examples in ch11, in the "Library
Templates" section, starting on page 406.

Cheers
A


_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to