Skip to content

Commit

Permalink
more context for Mojolicious template errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Nov 12, 2012
1 parent 45af12e commit 303e9bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/Mojolicious/Plugin/EPLRenderer.pm
Expand Up @@ -35,7 +35,7 @@ sub _epl {
# Inline
if (defined $inline) {
$c->app->log->debug('Rendering inline template.');
$$output = $mt->render($inline, $c);
$$output = $mt->name('inline template')->render($inline, $c);
}

# File
Expand All @@ -46,13 +46,13 @@ sub _epl {
# Try template
if (-r $path) {
$c->app->log->debug(qq{Rendering template "$t".});
$$output = $mt->name($t)->render_file($path, $c);
$$output = $mt->name("template $t")->render_file($path, $c);
}

# Try DATA section
elsif (my $d = $renderer->get_data_template($options)) {
$c->app->log->debug(qq{Rendering template "$t" from DATA section.});
$$output = $mt->name($t)->render($d, $c);
$$output = $mt->name("template $t from DATA section")->render($d, $c);
}

# No template
Expand Down
6 changes: 3 additions & 3 deletions t/mojolicious/lite_app.t
Expand Up @@ -683,19 +683,19 @@ $t->get_ok('/reserved?data=just-works&json=test')->status_is(200)
$t->get_ok('/inline/exception')->status_is(500)
->header_is(Server => 'Mojolicious (Perl)')
->header_is('X-Powered-By' => 'Mojolicious (Perl)')
->content_is("Died at template line 1.\n\n");
->content_is("Died at inline template line 1.\n\n");

# GET /data/exception
$t->get_ok('/data/exception')->status_is(500)
->header_is(Server => 'Mojolicious (Perl)')
->header_is('X-Powered-By' => 'Mojolicious (Perl)')
->content_is("Died at dies.html.ep line 2.\n\n");
->content_is("Died at template dies.html.ep from DATA section line 2.\n\n");

# GET /template/exception
$t->get_ok('/template/exception')->status_is(500)
->header_is(Server => 'Mojolicious (Perl)')
->header_is('X-Powered-By' => 'Mojolicious (Perl)')
->content_is("Died at dies_too.html.ep line 2.\n\n");
->content_is("Died at template dies_too.html.ep line 2.\n\n");

# GET /with-format
$t->get_ok('/with-format')->content_is("/without-format\n");
Expand Down

0 comments on commit 303e9bc

Please sign in to comment.