From f387dc246973f91b97c4434a19ea838ca4c5db69 Mon Sep 17 00:00:00 2001 From: Mathias Kende Date: Mon, 20 Dec 2021 23:51:13 +0100 Subject: [PATCH] Remove some unneeded statements --- lib/Mojolicious/Renderer.pm | 13 +------------ t/mojolicious/layouted_lite_app.t | 9 +++++++++ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/Mojolicious/Renderer.pm b/lib/Mojolicious/Renderer.pm index 808a06c72a..185cc298fc 100644 --- a/lib/Mojolicious/Renderer.pm +++ b/lib/Mojolicious/Renderer.pm @@ -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); @@ -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) = @_; diff --git a/t/mojolicious/layouted_lite_app.t b/t/mojolicious/layouted_lite_app.t index 886dea48f2..798be3d417 100644 --- a/t/mojolicious/layouted_lite_app.t +++ b/t/mojolicious/layouted_lite_app.t @@ -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}; @@ -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"); };