Skip to content

Commit

Permalink
Remove some unneeded statements
Browse files Browse the repository at this point in the history
  • Loading branch information
mkende committed Dec 20, 2021
1 parent 2d74508 commit f387dc2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
13 changes: 1 addition & 12 deletions lib/Mojolicious/Renderer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,8 @@ sub render {
my $content = $stash->{'mojo.content'} //= {};
local $content->{content} = $output =~ /\S/ ? $output : undef if $stash->{extends} || $stash->{layout};
if ($stash->{inline_layout}) {
@$options{qw(template inline)} = (undef, delete $stash->{inline_layout});
$options->{format} = $stash->{format} || $self->default_format;
@$options{inline} = delete $stash->{inline_layout};
if ($self->_render_template($c, \my $tmp, $options)) { $output = $tmp }
$content->{content} //= $output if $output =~ /\S/;
}
while ((my $next = _next($stash)) && !defined $inline) {
@$options{qw(handler template)} = ($stash->{handler}, $next);
Expand Down Expand Up @@ -220,15 +218,6 @@ sub _next {
return join '/', 'layouts', $layout;
}

sub _render_content {
my ($self, $c, $next, $options, $output) = @_;
my $stash = $c->stash;
@$options{qw(handler template)} = ($stash->{handler}, $next);
$options->{format} = $stash->{format} || $self->default_format;
if ($self->_render_template($c, \my $tmp, $options)) { $$output = $tmp }
$stash->{'mojo.content'}->{content} //= $$output if $$output =~ /\S/;
}

sub _render_template {
my ($self, $c, $output, $options) = @_;

Expand Down
9 changes: 9 additions & 0 deletions t/mojolicious/layouted_lite_app.t
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ get '/inline/inline_layout' => sub {
$c->render(inline => '<%= "inline!" %>', inline_layout => 'layouted_inline <%== content %>');
};

get '/inline/template_with_inline_layout' => sub {
my $c = shift;
$c->render(template => 'variants', format => 'txt', inline_layout => 'layouted_inline <%== content %>');
};

get '/inline/again' => {inline => 0};

get '/data' => {data => 0};
Expand Down Expand Up @@ -264,6 +269,10 @@ subtest 'Inline with layout' => sub {
->content_is("layouted_inline inline!\n\n");
};

subtest 'Template with inline layout' => sub {
$t->get_ok('/inline/template_with_inline_layout')->status_is(200)->content_is("layouted_inline Desktop!\n");
};

subtest '"0" inline template' => sub {
$t->get_ok('/inline/again')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')->content_is("0\n");
};
Expand Down

0 comments on commit f387dc2

Please sign in to comment.