Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
improved renderer log messages
  • Loading branch information
kraih committed May 4, 2012
1 parent 21cea5a commit 15b474f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 14 deletions.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -4,6 +4,7 @@ This file documents the revision history for Perl extension Mojolicious.
- Added remove method to Mojolicious::Routes::Route.
- Improved 32bit Perl support of Mojo::Transaction::WebSocket.
(mikemagowan, sri)
- Improved renderer log messages.
- Improved documentation.
- Improved tests.
- Fixed bug that prevented helper names from starting with "end". (Akron)
Expand Down
7 changes: 5 additions & 2 deletions lib/Mojolicious/Plugin/EPLRenderer.pm
Expand Up @@ -27,7 +27,10 @@ sub register {

# Cached
$mt ||= Mojo::Template->new;
if ($mt->compiled) { $$output = $mt->interpret($c) }
if ($mt->compiled) {
$c->app->log->debug("Rendering cached @{[$mt->name]}.");
$$output = $mt->interpret($c);
}

# Not cached
else {
Expand Down Expand Up @@ -55,7 +58,7 @@ sub register {
elsif (my $d = $r->get_data_template($options, $t)) {
$c->app->log->debug(
qq/Rendering template "$t" from DATA section./);
$mt->name(qq/template from DATA section "$t"/);
$mt->name(qq/template "$t" from DATA section/);
$$output = $mt->render($d, $c);
}

Expand Down
7 changes: 2 additions & 5 deletions lib/Mojolicious/Plugin/EPRenderer.pm
Expand Up @@ -11,11 +11,8 @@ sub register {
my ($self, $app, $conf) = @_;
$conf ||= {};

# Config
my $name = $conf->{name} || 'ep';
my $template = $conf->{template} || {};

# Custom sandbox
my $template = $conf->{template} || {};
$template->{namespace} //= 'Mojo::Template::SandBox::'
. md5_sum(($ENV{MOJO_EXE} || ref $app) . $$);

Expand All @@ -24,7 +21,7 @@ sub register {

# Add "ep" handler
$app->renderer->add_handler(
$name => sub {
$conf->{name} || 'ep' => sub {
my ($r, $c, $output, $options) = @_;

# Generate name
Expand Down
9 changes: 3 additions & 6 deletions lib/Mojolicious/Plugin/PODRenderer.pm
Expand Up @@ -20,16 +20,13 @@ sub register {
my ($self, $app, $conf) = @_;
$conf ||= {};

# Config
my $name = $conf->{name} || 'pod';
my $preprocess = $conf->{preprocess} || 'ep';

# Add "pod" handler
my $preprocess = $conf->{preprocess} || 'ep';
$app->renderer->add_handler(
$name => sub {
$conf->{name} || 'pod' => sub {
my ($r, $c, $output, $options) = @_;

# Preprocess with ep and then render
# Preprocess and render
return unless $r->handlers->{$preprocess}->($r, $c, $output, $options);
$$output = _pod_to_html($$output);
return 1;
Expand Down
2 changes: 1 addition & 1 deletion t/mojolicious/lite_app.t
Expand Up @@ -700,7 +700,7 @@ $t->get_ok('/inline/exception')->status_is(500)
$t->get_ok('/data/exception')->status_is(500)
->header_is(Server => 'Mojolicious (Perl)')
->header_is('X-Powered-By' => 'Mojolicious (Perl)')
->content_is(qq/Died at template from DATA section "dies.html.ep" line 2/
->content_is(qq/Died at template "dies.html.ep" from DATA section line 2/
. qq/, near "123".\n\n/);

# GET /template/exception
Expand Down

0 comments on commit 15b474f

Please sign in to comment.