-
Notifications
You must be signed in to change notification settings - Fork 280
Closed
Description
While upgrading to 0.16200 I noticed plugins that use the before_template hook die with:
[TestApp:23715] error @2015-09-29 18:20:25> Route exception: Can't call method "params" on an undefined value at /usr/local/perlbrew/perls/5.19.3/lib/site_perl/5.19.3/Dancer2/Core/Role/Template.pm line 180. in /usr/local/perlbrew/perls/5.19.3/lib/site_perl/5.19.3/Dancer2/Core/App.pm l. 1273
Example to replicate this:
App (test) code:
use Plack::Test;
use HTTP::Request::Common;
{
package TestApp;
use Dancer2;
hook before_template => sub {
# do something, or nothing...
};
set template => 'template_toolkit';
get '/' => sub {
template 't.tt', { hi => "hello" },
};
};
my $test = Plack::Test->create( TestApp->to_app );
my $res = $test->request(GET "/");
print $res->content;With a very basic template named views/t.tt
[% hi %]The problem, I guess, is the order of operations here. When I move the set template => 'template_toolkit'; above the hook, all works as expected, but that'd means I have to use constructs like this to use plugins:
BEGIN {
use Dancer2;
set template => 'template_toolkit';
};
use Dancer2::Plugin::Something::That::Adds::A::Hook;Not ideal.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels