Subject: | Auto determining template filename broken |
Perl: 5.10.0 (ActiveState)
In what is most likely the common use case, if a user allows the view to
determine the location of the template based upon the action (rather
than specifying it in $c->stash->{template}, the expected filename of
the template is created wrong. There is a fairly simple workaround.
To see this:
1) Create a Catalyst project and a View using
Catalyst::View::Excel::Template::Plus with the following config:
__PACKAGE__->config(
TEMPLATE_EXTENSION => '.tt2',
);
Then, create a controller for your app that is similar to this one:
sub myaction : Local {
my ($self,$c) = @_;
$c->stash->{'name'} = 'Leanan';
$c->stash->{'current_view'} = 'ReportBuilder::View::Excel';
}
Observed: get_template_filename returns the template's file name as
myaction.xml..tt2. Notice the extra dot. The file will never exist.
Expected: get_template_filename should return the template's file name
as myaction.xml.tt2
Workaround:
Change the TEMPLATE_EXTENSION config val to 'tt2' instead of '.tt2'.
However, since in the Catalyst tutorial, when creating the TT view it
specifies TEMPLATE_EXTENSION to be '.tt2', a user trying to use this
View might assume that they should set the template extension similarly.
Suggested Patch:
Change line 76 from
($c->action . '.xml.' . $self->config->{TEMPLATE_EXTENSION});
to
($c->action . '.xml' . $self->config->{TEMPLATE_EXTENSION});
--
Insanity is more than a state of mind. It's a way of life!