fix for defaults layout
This commit is contained in:
committed by
Graham Ollis
parent
9be62a9c2c
commit
fe963f6511
@@ -81,12 +81,16 @@ sub _render {
|
|||||||
$t = 'inline' if defined $inline;
|
$t = 'inline' if defined $inline;
|
||||||
return unless $t;
|
return unless $t;
|
||||||
|
|
||||||
|
|
||||||
my $helper = Mojolicious::Plugin::TtRenderer::Helper->new(ctx => $c);
|
my $helper = Mojolicious::Plugin::TtRenderer::Helper->new(ctx => $c);
|
||||||
|
|
||||||
# Purge previous result
|
# Purge previous result
|
||||||
$$output = '';
|
$$output = '';
|
||||||
|
|
||||||
|
# fixes for t/lite_app_with_default_layouts.t
|
||||||
|
unless ($c->stash->{layout}) {
|
||||||
|
$c->stash->{content} ||= $c->stash->{'mojo.content'}->{content};
|
||||||
|
}
|
||||||
|
|
||||||
my @params = ({%{$c->stash}, c => $c, h => $helper}, $output, {binmode => ':utf8'});
|
my @params = ({%{$c->stash}, c => $c, h => $helper}, $output, {binmode => ':utf8'});
|
||||||
my $provider = $self->tt->{SERVICE}->{CONTEXT}->{LOAD_TEMPLATES}->[0];
|
my $provider = $self->tt->{SERVICE}->{CONTEXT}->{LOAD_TEMPLATES}->[0];
|
||||||
$provider->options($options);
|
$provider->options($options);
|
||||||
|
|||||||
37
t/lite_app_with_default_layouts.t
Normal file
37
t/lite_app_with_default_layouts.t
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
BEGIN { $ENV{MOJO_MODE}='testing'; };
|
||||||
|
|
||||||
|
use utf8;
|
||||||
|
|
||||||
|
use Test::More tests => 3;
|
||||||
|
|
||||||
|
use Mojolicious::Lite;
|
||||||
|
use Mojo::ByteStream 'b';
|
||||||
|
use Test::Mojo;
|
||||||
|
use File::Temp qw( tempdir );
|
||||||
|
|
||||||
|
# Silence
|
||||||
|
app->log->level('fatal');
|
||||||
|
|
||||||
|
use_ok('Mojolicious::Plugin::TtRenderer::Engine');
|
||||||
|
|
||||||
|
plugin 'tt_renderer' => {template_options => {PRE_CHOMP => 1, POST_CHOMP => 1, TRIM => 1, COMPILE_DIR => tempdir( CLEANUP => 1 ) }};
|
||||||
|
app->defaults(layout => 'wrapper');
|
||||||
|
|
||||||
|
get '/test' => 'test';
|
||||||
|
|
||||||
|
my $t = Test::Mojo->new;
|
||||||
|
|
||||||
|
$t->get_ok('/test')->content_is("WS-hello-EW");
|
||||||
|
|
||||||
|
__DATA__
|
||||||
|
|
||||||
|
@@ test.html.tt
|
||||||
|
hello
|
||||||
|
|
||||||
|
@@ layouts/wrapper.html.tt
|
||||||
|
WS-[%- content -%]-EW
|
||||||
Reference in New Issue
Block a user