Permalink
Browse files

fix for defaults layout

  • Loading branch information...
fayland committed Apr 24, 2013
1 parent fd6e630 commit 95d9ee5c356fa3f398b2deed9611ba47b69a890b
Showing with 42 additions and 1 deletion.
  1. +5 −1 lib/Mojolicious/Plugin/TtRenderer/Engine.pm
  2. +37 −0 t/lite_app_with_default_layouts.t
@@ -81,12 +81,16 @@ sub _render {
$t = 'inline' if defined $inline;
return unless $t;
my $helper = Mojolicious::Plugin::TtRenderer::Helper->new(ctx => $c);
# Purge previous result
$$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 $provider = $self->tt->{SERVICE}->{CONTEXT}->{LOAD_TEMPLATES}->[0];
$provider->options($options);
@@ -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

0 comments on commit 95d9ee5

Please sign in to comment.