Tony Bowden wrote: > In the "Resource Providers and Consumers" section of this > (http://template-toolkit.org/oscon2003/tt3/mgp00014.html) ISTR you > saying that something like this already existed in TT2, but was > un(der)documented...
Yes, the PREFIX_MAP can be used to name providers. It's only documented in the Changes file (repro below) because there's a good chance that it won't be called PREFIX_MAP or will be implented a different way, as soon as I figure out what that better way is. > Do I recall correctly? Does that mean you were in my talk and didn't come and introduce yourself afterwards? How am I ever expected to put faces to names? :-) Here's the PREFIX_MAP section: * Templates specified to INCLUDE, PROCESS, WRAPPER and INSERT can now be given a prefix (delimited by ':', as in "file:blahblah.txt" or "http://www.tt2.org/index.html", for example) which maps them to a particular template provider or providers. A PREFIX_MAP configuration option can be specified as a hash array mapping prefix names to a reference to a list of providers. For convenience, you can also specify the argument as a string of integers, delimited by any non-numerical sequence, to indicate indices into the LOAD_TEMPLATES provider list. e.g. my $template = Template->new({ LOAD_TEMPLATES => [ $foo, $bar, $baz, $wiz ], PREFIX_MAP => { src => '0, 2', # $foo and $baz lib => '1, 2', # $bar and $baz all => '0, 1, 2', # $foo, $bar and $baz } }); Thus [% INCLUDE src:hello.tt2 %] indicates the 'hello.tt2' template to be provided by $foo or $baz, [% INCLUDE lib:hello.tt2 %] is mapped to $bar and $baz, [% INCLUDE all:hello.tt2 %] can be provided by $foo, $bar or $baz, and the default [% INCLUDE hello.tt2 %] is mapped to the entire LOAD_TEMPLATES list: $foo, $bar, $baz and $wiz. This is initially useful for things like ttree which would like a way to differentiate between templates in one place and templates in another. It can also be used, of course, to provider special providers for certain file type, as in http://fetch.some.file.com/blah/blah/... Cheers A _______________________________________________ templates mailing list [EMAIL PROTECTED] http://lists.template-toolkit.org/mailman/listinfo/templates
