Quoting darren chamberlain ([EMAIL PROTECTED]):

I agree that such a iteration would be needed if LOAD_TEMPLATES
contained multiple objects.

I'd be interested to know if anyone actually uses TT2 where the
LOAD_TEMPLATES data member contains an array ref of Template::Provider
objects and/or objects that have been sub-classed from Template::Provider

I've looked at this and found it challenging to wrap my brain around
it (notwithstanding that the documentation says you should be able to
do that in theory).

> But the problem there is that a Template::Context instance has
> potentially more than one Template::Provider instance, in the
> LOAD_TEMPLATES data member:
> 
>      66 # ...If nothing is defined, then we
>      67 # iterate through the LOAD_TEMPLATES providers list as a 'chain of 
>      68 # responsibility' (see Design Patterns) asking each object to fetch() 
>      69 # the template if it can.
> 
> And then it is used as such:
> 
>     121     $providers = $self->{ PREFIX_MAP }->{ default }
>     122               || $self->{ LOAD_TEMPLATES }
>     123         unless $providers;
>     124    
>     125     # finally we try the regular template providers which will 
>     126     # handle references to files, text, etc., as well as templates
>     127     # reference by name
>     128     foreach my $provider (@$providers) {
>     129         ($template, $error) = $provider->fetch($name);
> 
> Thus, a method that sets the INCLUDE_PATH would need to set it in
> each of the elements of LOAD_TEMPLATES.  You could, of course, do
> something like:
> 
> package Template::Content;
> sub include_path {
>     my $self = shift;
>     my $paths = isa($_[0], 'ARRAY') ? shift : [ @_ ];
> 
>     for my $provider (@{$self->{ LOAD_TEMPLATES }}) {
>         $provider->include_path($paths);
>     }
> 
>     return $paths;
> }
> 
> But is that The Right Thing To Do?
> 
> (darren)
> 
> -- 
> An operating system is just a name you give the features you left
> out of your editor.
>     -- Per Abrahamsen in comp.emacs
> 
> _______________________________________________
> templates mailing list
> [EMAIL PROTECTED]
> http://www.template-toolkit.org/mailman/listinfo/templates


Reply via email to