Skip to content

Instantly share code, notes, and snippets.

@sharifulin
Created March 17, 2010 18:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save sharifulin/335531 to your computer and use it in GitHub Desktop.
Save sharifulin/335531 to your computer and use it in GitHub Desktop.
Nested layouts for the Mojolicious
#!/usr/bin/env perl
use Mojolicious::Lite;
get '/' => 'index';
get '/ok' => 'index_ok';
use Test::More;
plan tests => 6;
use Test::Mojo;
my $result = "<!doctype html><html>\n<head><title>Funky!</title></head>\n<body>\nYea baby!\n\n</body>\n</html>\n";
my $t = Test::Mojo->new;
$t->get_ok('/ok')->status_is(200)->content_is($result);
$t->get_ok('/' )->status_is(200)->content_is($result);
__DATA__
@@ index.html.ep
% layout 'funky';
Yea baby!
@@ layouts/funky.html.ep
% layout 'base';
<head><title>Funky!</title></head>
<body>
<%== content %>
</body>
@@ layouts/base.html.ep
<!doctype html><html>
<%== content %>
</html>
@@ index_ok.html.ep
% layout 'funky_base';
Yea baby!
@@ layouts/funky_base.html.ep
<!doctype html><html>
<head><title>Funky!</title></head>
<body>
<%== content %>
</body>
</html>
@olegwtf
Copy link

olegwtf commented Nov 21, 2012

What he said? Why this doesn't work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment