Skip to content

Commit

Permalink
fixed small rendering bug in Mojolicious::Plugin::PODRenderer
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed May 3, 2012
1 parent 2c366b5 commit 8c53b68
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
3 changes: 2 additions & 1 deletion Changes
Expand Up @@ -9,6 +9,7 @@ This file documents the revision history for Perl extension Mojolicious.
- Fixed bug that prevented helper names from starting with "end". (Akron)
- Fixed bug that prevented helper names from ending with "begin".
- Fixed empty frame handling in Mojo::Transaction::WebSocket.
- Fixed small rendering bug in Mojolicious::Plugin::PODRenderer.

2.92 2012-04-30
- Added commands attribute to Mojolicious.
Expand Down Expand Up @@ -1768,7 +1769,7 @@ This file documents the revision history for Perl extension Mojolicious.
- Fixed a small Test::Mojo bug.
- Fixed multiple route condition bugs. (esskar)
- Fixed a small relative path bug in Mojo::URL.
- Fixed pod renderer bug. (vti)
- Fixed POD renderer bug. (vti)
- Fixed a multipart parser bug affecting mostly file uploads.
- Fixed input tag helper escaping. (vti)
- Fixed url_for WebSocket support.
Expand Down
14 changes: 6 additions & 8 deletions lib/Mojolicious/Plugin/PODRenderer.pm
Expand Up @@ -30,8 +30,9 @@ sub register {
my ($r, $c, $output, $options) = @_;

# Preprocess with ep and then render
$$output = _pod_to_html($$output)
if $r->handlers->{$preprocess}->($r, $c, $output, $options);
return unless $r->handlers->{$preprocess}->($r, $c, $output, $options);
$$output = _pod_to_html($$output);
return 1;
}
);

Expand Down Expand Up @@ -115,8 +116,7 @@ sub register {
}

sub _pod_to_html {
my $pod = shift;
return unless defined $pod;
return unless defined(my $pod = shift);

# Block
$pod = $pod->() if ref $pod eq 'CODE';
Expand All @@ -129,10 +129,8 @@ sub _pod_to_html {
$parser->html_footer('');

# Parse
my $output;
$parser->output_string(\$output);
eval { $parser->parse_string_document("$pod") };
return $@ if $@;
$parser->output_string(\(my $output));
return $@ unless eval { $parser->parse_string_document("$pod"); 1 };

# Filter
$output =~ s|<a name='___top' class='dummyTopAnchor'\s*?></a>\n||g;
Expand Down
8 changes: 7 additions & 1 deletion t/mojolicious/pod_renderer_lite_app.t
Expand Up @@ -6,7 +6,7 @@ BEGIN {
$ENV{MOJO_REACTOR} = 'Mojo::Reactor::Poll';
}

use Test::More tests => 32;
use Test::More tests => 35;

# "Amy get your pants back on and get to work.
# They think were making out.
Expand All @@ -33,6 +33,9 @@ post '/' => 'index';
# GET /block
post '/block' => 'block';

# GET /empty
get '/empty' => {inline => '', handler => 'pod'};

my $t = Test::Mojo->new;

# Simple POD template
Expand All @@ -49,6 +52,9 @@ $t->post_ok('/block')->status_is(200)
->content_like(qr#test321\s+<h2>lalala</h2>\s+<p><code>test</code></p>#)
->content_like(qr/Gray/);

# Empty
$t->get_ok('/empty')->status_is(200)->content_is('');

# Perldoc browser (Welcome)
$t->get_ok('/perldoc')->status_is(200)->text_is('h1 a[id="NAME"]', 'NAME')
->text_is('a[id="TUTORIAL"]', 'TUTORIAL')
Expand Down

0 comments on commit 8c53b68

Please sign in to comment.