Skip to content

Commit

Permalink
empty templates should get rendered too
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 28, 2016
1 parent 01a5bff commit 2bfc9aa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Changes
@@ -1,5 +1,7 @@

6.51 2016-02-28
- Fixed bug in Mojolicious::Plugin::EPLRenderer where empty templates from the
DATA section would be ignored.

6.50 2016-02-27
- Added throw method to Mojo::Exception.
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Plugin/EPLRenderer.pm
Expand Up @@ -40,7 +40,7 @@ sub _epl {
}

# Try DATA section
elsif (my $d = $renderer->get_data_template($options)) {
elsif (defined(my $d = $renderer->get_data_template($options))) {
$log->debug(qq{Rendering template "$name" from DATA section});
$$output
= $mt->name(qq{template "$name" from DATA section})->render($d, $c);
Expand Down
7 changes: 7 additions & 0 deletions t/mojolicious/lite_app.t
Expand Up @@ -55,6 +55,8 @@ hook before_render => sub {
$args->{test} = 'after' if $c->stash->{to_string};
};

get '/empty';

get '/☃' => sub {
my $c = shift;
$c->render(text => $c->url_for . $c->url_for({}) . $c->url_for('current'));
Expand Down Expand Up @@ -466,6 +468,9 @@ is $t->app->build_controller->render_to_string('index', handler => 'epl'),
is $t->app->build_controller->render_to_string(inline => '0'), "0\n",
'right result';

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

# Unicode snowman
$t->get_ok('/☃')->status_is(200)
->content_is('/%E2%98%83/%E2%98%83/%E2%98%83');
Expand Down Expand Up @@ -1030,6 +1035,8 @@ $t->get_ok('/dynamic/inline')->status_is(200)->content_is("dynamic inline 2\n");
done_testing();

__DATA__
@@ empty.html.ep
@@ with-format.html.ep
<%= url_for 'without-format' %>
Expand Down

0 comments on commit 2bfc9aa

Please sign in to comment.