>> I think this would be useful for large projects which need to  
>> organize
>> templates into a directory hierarchy. Helper templates could be  
>> stored
>> in the same directories as the templates that use them and accessed
>> with a short path.

We use a technique where we manipulate the TEMPLATE_PATH before  
executing the View rendering (this is a Catalyst app, but that's  
probably not terribly important). There is a directory tree structure  
for all the templates, which in this case mirrors the components of  
the URI.

So a call to http://server/application/category1/type1/subtype1/report1

might want a template/component called rpt1_component.tt

By tweaking the TEMPLATE_PATH on each request, TT winds up looking for:
tt/category1/type1/subtype1/report1/rpt_component.tt
tt/category1/type1/subtype1/rpt_component.tt
tt/category1/type1/rpt_component.tt
tt/category1/rpt_component.tt
tt/base/rpt_component.tt

The last of these is obviously the default version. It can be over- 
ridden at any level with a custom version that suits that branch of  
the reporting tree. You can also exclude a particular component in a  
certain context by placing an empty file with that template's name  
somewhere. It's a very powerful technique. I'm not near the Catalyst  
code at the moment, but will post it later if it's of interest.

cheers
RET

_____________________________________________________
What do we want? Instant gratification! When do we want it? ...

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

Reply via email to