diff --git a/lib/Mojolicious/Plugin/TtRenderer/Engine.pm b/lib/Mojolicious/Plugin/TtRenderer/Engine.pm index cb85120..3a87e3f 100644 --- a/lib/Mojolicious/Plugin/TtRenderer/Engine.pm +++ b/lib/Mojolicious/Plugin/TtRenderer/Engine.pm @@ -85,9 +85,7 @@ sub _render { # Error unless ($ok) { - my $e = Mojo::Exception->new( - $self->tt->error.'', - $self->tt->service->process(defined $inline ? \$inline : $t)); + my $e = Mojo::Exception->new($self->tt->error.''); $$output = ''; $c->app->log->error(qq/Template error in "$t": $e/); $c->render_exception($e); diff --git a/t/templates/conditional-exception.html.tt b/t/templates/conditional-exception.html.tt new file mode 100644 index 0000000..8a6ba36 --- /dev/null +++ b/t/templates/conditional-exception.html.tt @@ -0,0 +1,4 @@ +foo +[% PROCESS doesnotexist.tt IF do_process %] +bar + diff --git a/t/tt_plugin_lite_app.t b/t/tt_plugin_lite_app.t index 94ae154..575b588 100644 --- a/t/tt_plugin_lite_app.t +++ b/t/tt_plugin_lite_app.t @@ -15,7 +15,7 @@ BEGIN { $ENV{MOJO_TMPDIR} ||= File::Temp::tempdir } # Make sure sockets are working plan skip_all => 'working sockets required for this test!' unless Mojo::IOLoop->new->generate_port; -plan tests => 3; +plan tests => 6; # Leela: OK, this has gotta stop. I'm going to remind Fry of his humanity the way only a woman can. # Farnsworth: You're going to do his laundry? @@ -30,13 +30,18 @@ plugin 'tt_renderer'; app->log->level('error'); # GET / -get '/' => 'index'; +get '/' => 'index'; +get '/blow' => sub { + shift->render(template => 'conditional-exception', do_process => 1); +}; + my $t = Test::Mojo->new; # Simple TT template $t->get_ok('/')->status_is(200) ->content_like(qr/test123456/); +$t->get_ok('/blow')->status_is(500)->content_like(qr/file error - doesnotexist.tt: No such file or directory/); eval " use Devel::Cycle 'find_cycle';