diff --git a/Makefile.PL b/Makefile.PL index 40502dc..9cbf198 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -37,7 +37,7 @@ WriteMakefile( PREREQ_PM => { 'Text::Haml' => '0.990103', - 'Mojolicious' => '0.999924' + 'Mojolicious' => '1.13' }, test => {TESTS => 't/*.t t/*/*.t t/*/*/*.t t/*/*/*/*.t'} diff --git a/lib/MojoX/Renderer/Haml.pm b/lib/MojoX/Renderer/Haml.pm index 959e517..feae04d 100644 --- a/lib/MojoX/Renderer/Haml.pm +++ b/lib/MojoX/Renderer/Haml.pm @@ -31,6 +31,7 @@ sub _render { unless ($path = $c->stash->{'template_path'}) { $path = $r->template_path($options); } + return unless defined $path; my $list = join ', ', sort keys %{$c->stash}; my $cache = b("$path($list)")->md5_sum->to_string; @@ -47,6 +48,7 @@ sub _render { if ( $c->app->mode ne 'development' && $haml && $haml->compiled) { $haml->helpers_arg($c); + $c->app->log->debug("Rendering cached $t."); $$output = $haml->interpret(%args); } @@ -55,41 +57,35 @@ sub _render { $haml ||= Text::Haml->new(escape => $ESCAPE); $haml->helpers_arg($c); - $haml->helpers($r->helper); + $haml->helpers($r->helpers); # Try template if (-r $path) { + $c->app->log->debug("Rendering template '$t'."); $$output = $haml->render_file($path, %args); } # Try DATA section - elsif (my $d = $r->get_inline_template($c, $t)) { + elsif (my $d = $r->get_data_template($c, $t)) { + $c->app->log->debug("Rendering template '$t' from DATA section."); $$output = $haml->render($d, %args); } # No template else { - $c->app->log->error(qq/Template "$t" missing or not readable./); - $c->render_not_found; + $c->app->log->debug(qq/Template "$t" missing or not readable./); return; } } unless (defined $$output) { $$output = ''; - - my $e = Mojo::Exception->new($haml->error); - - $c->app->log->error( qq/Template error in "$t": / . $haml->error); - - $c->render_exception($e); - - return 0; + die(qq/Template error in "$t": / . $haml->error); } $r->{_haml_cache}->{$cache} ||= $haml; - return 1; + return ref $$output ? die($$output) : 1; } 1; diff --git a/t/lite_app.t b/t/lite_app.t index 45c7a42..a8af9f5 100644 --- a/t/lite_app.t +++ b/t/lite_app.t @@ -6,7 +6,7 @@ use warnings; use Test::More tests => 18; use Test::Mojo; -use Mojo::Client; +use Mojo::UserAgent; use Mojolicious::Lite; # Silence @@ -25,7 +25,6 @@ get '/error' => 'error'; get '/with_wrapper' => 'with_wrapper'; my $t = Test::Mojo->new; -$t->client(Mojo::Client->new); # No cache $t->get_ok('/')->status_is(200)->content_is("1 + 1 < 2\n"); @@ -43,7 +42,7 @@ $t->get_ok('/with_wrapper')->status_is(200)->content_is("Hello!\n\n") $t->get_ok('/foo')->status_is(404)->content_is("Not found\n"); # Error -$t->get_ok('/error')->status_is(500)->content_like(qr/^Exception:\nsyntax error/); +$t->get_ok('/error')->status_is(500)->content_like(qr/^Exception:.+syntax error/s); 1; __DATA__