Skip to content

Commit

Permalink
added experimental layout support for inline templates
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Nov 26, 2011
1 parent e6b1036 commit a19d712
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Changes
@@ -1,6 +1,7 @@
This file documents the revision history for Perl extension Mojolicious.

2.33 2011-11-25 00:00:00
2.33 2011-11-26 00:00:00
- Added EXPERIMENTAL layout support for inline templates.
- Improved Mojo::EventEmitter performance slightly.
- Improved documentation.

Expand Down
1 change: 1 addition & 0 deletions lib/Mojolicious/Renderer.pm
Expand Up @@ -132,6 +132,7 @@ sub render {
return unless $self->_render_template($c, \$output, $options);
$content->{content} = $output
if ($c->stash->{extends} || $c->stash->{layout});
delete $options->{inline};
}

# Extends
Expand Down
20 changes: 19 additions & 1 deletion t/mojolicious/layouted_lite_app.t
Expand Up @@ -7,7 +7,7 @@ BEGIN {
$ENV{MOJO_IOWATCHER} = 'Mojo::IOWatcher';
}

use Test::More tests => 87;
use Test::More tests => 97;

use FindBin;
use lib "$FindBin::Bin/lib";
Expand Down Expand Up @@ -110,6 +110,12 @@ get '/withblocklayout' => sub {
# GET /content_for
get '/content_for';

# GET /inline
get '/inline' => {inline => '<%= "inline!" %>'};

# GET /inline/green
get '/inline/green' => {inline => '<% layout "green"; %><%= "inline!" %>'};

my $t = Test::Mojo->new;

# GET /works
Expand Down Expand Up @@ -223,6 +229,18 @@ $t->get_ok('/content_for')->status_is(200)
->header_is('X-Powered-By' => 'Mojolicious (Perl)')
->content_is("DefaultThis\n\nseems\nto\nHello world!\n\nwork!\n\n");

# GET /inline
$t->get_ok('/inline')->status_is(200)
->header_is(Server => 'Mojolicious (Perl)')
->header_is('X-Powered-By' => 'Mojolicious (Perl)')
->content_is("Defaultinline!\n\n");

# GET /inline/green
$t->get_ok('/inline/green')->status_is(200)
->header_is(Server => 'Mojolicious (Perl)')
->header_is('X-Powered-By' => 'Mojolicious (Perl)')
->content_is("Greeninline!\n\n");

__DATA__
@@ layouts/default.html.ep
Default<%= title %><%= content %>
Expand Down

0 comments on commit a19d712

Please sign in to comment.