Merge remote branch 'marcusramberg/master'

This commit is contained in:
Ask Bjørn Hansen committed 2011-01-22 10:33:09 -08:00
commit 1e7dc3044b
2 files changed
+9 -12

No files matched your search

+5 -8
View File
@@ -52,11 +52,12 @@ sub _init {
return $self; return $self;
} }
use Data::Dumper;
sub _render { sub _render {
my ($self, $renderer, $c, $output, $options) = @_; my ($self, $renderer, $c, $output, $options) = @_;
# Inline # Inline
my $inline = $c->{stash}->{inline}; my $inline = $options->{inline};
# Template # Template
my $t = $renderer->template_name($options); my $t = $renderer->template_name($options);
@@ -77,14 +78,10 @@ sub _render {
# Error # Error
unless ($ok) { unless ($ok) {
my $e = $self->tt->error;
if ($e =~ m/not found/) {
$c->app->log->error(qq/Template "$t" missing or not readable./);
$c->render_not_found;
return;
}
my $e = Mojo::Exception->new(
$self->tt->error.'',
$self->tt->service->process(defined $inline ? \$inline : $path));
$$output = ''; $$output = '';
$c->app->log->error(qq/Template error in "$t": $e/); $c->app->log->error(qq/Template error in "$t": $e/);
$c->render_exception($e); $c->render_exception($e);
+4 -4
View File
@@ -34,7 +34,7 @@ get '/unknown_helper' => 'unknown_helper';
get '/on-disk' => 'foo'; get '/on-disk' => 'foo';
get '/foo/:message' => 'index'; get '/bar/:message' => 'bar';
get '/inline' => sub { shift->render(inline => '[% 1 + 1 %]', handler => 'tt') }; get '/inline' => sub { shift->render(inline => '[% 1 + 1 %]', handler => 'tt') };
@@ -44,7 +44,7 @@ my $t = Test::Mojo->new;
$t->get_ok('/exception')->status_is(500)->content_like(qr/error/i); $t->get_ok('/exception')->status_is(500)->content_like(qr/error/i);
# Normal rendering # Normal rendering
$t->get_ok('/foo/hello')->content_is("hello"); $t->get_ok('/bar/hello')->content_is("hello");
# With include # With include
$t->get_ok('/with_include')->content_is("HelloInclude!Hallo"); $t->get_ok('/with_include')->content_is("HelloInclude!Hallo");
@@ -56,7 +56,7 @@ $t->get_ok('/with_wrapper')->content_is("wrapped");
#$t->get_ok('/with_auto_wrapper')->content_is("wrapped"); #$t->get_ok('/with_auto_wrapper')->content_is("wrapped");
# Unicode # Unicode
$t->get_ok('/unicode')->content_is(b("привет")->encode('UTF-8')->to_string); $t->get_ok('/unicode')->content_is("привет");
# Helpers # Helpers
$t->get_ok('/helpers')->content_is("/helpers"); $t->get_ok('/helpers')->content_is("/helpers");
@@ -75,7 +75,7 @@ $t->get_ok('/inline')->status_is(200)->content_is('2');
__DATA__ __DATA__
@@ index.html.tt @@ bar.html.tt
[% message %] [% message %]
@@ error.html.tt @@ error.html.tt