in reply to Which template failed to load?
One way of doing this would be to write a subclass of Template::Provider that records the location of the templates it fetches. For example:
package Recording::Provider; use base qw(Template::Provider); my $Template_name; sub last_template { $Template_name }; sub fetch { my $self = shift; return( $self->SUPER::fetch($Template_name = shift) ); };
You can then add this as the last provider in the chain - and the only one that handles the default template.
my @config = ( INCLUDE_PATH => '/Users/adrianh/Desktop/template/', ); my $template = Template->new({ EVAL_PERL => 1, LOAD_TEMPLATES => [ Template::Provider->new(@config), Recording::Provider->new(@config, DEFAULT => 'default.t2'), ], }) or die "could not make template\n";
Your default.t2 template can then do something like this to show what template failed to load:
[% PERL %] print Recording::Provider->last_template [% END %] failed to load
That last bit should probably more elegently implemented as a plugin - but I leave that as an exercise for the reader :-)
|
|---|