Mojolicious-Plugin-PlackMiddleware

 view release on metacpan or  search on metacpan

xt/compat/layouted_lite_app.t  view on Meta::CPAN

$t->get_ok('/nested-includes')->status_is(200)
  ->header_is(Server => 'Mojolicious (Perl)')
  ->content_is("layouted Nested <Hello>\n[\n  1,\n  2\n]\nthere<br>!\n\n\n\n");

# Included template with localized stash values
$t->get_ok('/localized/include')->status_is(200)
  ->header_is(Server => 'Mojolicious (Perl)')
  ->content_type_is('text/html;charset=UTF-8')
  ->content_is("lmth\n\noof\n\n\n123 2dezilacol\noof 1dezilacol");

# Filter
$t->get_ok('/plain/reverse')->status_is(200)
  ->header_is(Server => 'Mojolicious (Perl)')->content_type_is('text/plain')
  ->content_is('oof!olleH');

# Layout in render call
$t->get_ok('/outerlayout')->status_is(200)
  ->header_is(Server => 'Mojolicious (Perl)')
  ->content_is("layouted <Hello>\n[\n  1,\n  2\n]\nthere<br>!\n\n\n");

# Extends in render call
$t->get_ok('/outerextends')->status_is(200)
  ->header_is(Server => 'Mojolicious (Perl)')
  ->content_is("layouted <Hello>\n[\n  1,\n  2\n]\nthere<br>!\n\n\n");

# Layout in route
$t->get_ok('/outerlayouttwo')->status_is(200)
  ->header_is(Server => 'Mojolicious (Perl)')
  ->content_is("layouted <Hello>\n[\n  1,\n  2\n]\nthere<br>!\n\n\n");

# Included template with layout
$t->get_ok('/outerinnerlayout')->status_is(200)
  ->header_is(Server => 'Mojolicious (Perl)')
  ->content_is("layouted Hello\nlayouted [\n  1,\n  2\n]\nthere<br>!\n\n\n\n");

# Layout with block
$t->get_ok('/withblocklayout')->status_is(200)
  ->header_is(Server => 'Mojolicious (Perl)')
  ->content_is("\nwith_block \n\nOne: one\nTwo: two\n\n");

# Content blocks
$t->get_ok('/content_for')->status_is(200)
  ->header_is(Server => 'Mojolicious (Perl)')
  ->content_is("DefaultThis\n\nseems\nto\nHello    world!\n\nwork!\n\n");
$t->get_ok('/content_with')->status_is(200)
  ->header_is(Server => 'Mojolicious (Perl)')
  ->content_is("Default\n\nSomething <b>else</b>!\n\n\n<br>Hello world!\n\n");

# Inline template
$t->get_ok('/inline')->status_is(200)
  ->header_is(Server => 'Mojolicious (Perl)')->content_is("inline!\n");

# "0" inline template
$t->get_ok('/inline/again')->status_is(200)
  ->header_is(Server => 'Mojolicious (Perl)')->content_is("0\n");

# "0" data
$t->get_ok('/data')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
  ->content_is(0);

# Variants (desktop)
$t->get_ok('/variants.txt')->status_is(200)
  ->content_type_is('text/plain;charset=UTF-8')
  ->content_is('Variant: Desktop!');

# Variants (tablet)
$t->get_ok('/variants.txt?device=tablet')->status_is(200)
  ->content_type_is('text/plain;charset=UTF-8')
  ->content_is('Variant: Tablet!');

# Variants (desktop fallback)
$t->get_ok('/variants.txt?device=phone')->status_is(200)
  ->content_type_is('text/plain;charset=UTF-8')
  ->content_is('Variant: Desktop!');

# Variants ("0")
$t->get_ok('/variants.txt?device=0')->status_is(200)
  ->content_type_is('text/plain;charset=UTF-8')
  ->content_is('Another variant: Desktop!');

done_testing();

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

@@ layouts/green.html.ep
Green<%= title %><%= content %>

@@ layouts/mixed.txt.ep
Mixed <%= content %>

@@ blue.html.ep
Blue<%= title %><%= content %>

@@ works.html.ep
% title 'Just works';
% layout 'green' if param 'green';
% extends 'blue' if param 'blue';
This <template> just works!

@@ mixed.html.ep
% layout 'mixed', format => 'txt';
formats

@@ exception.html.ep
% title 'Exception happened';
% layout 'green' if param 'green';
% extends 'blue' if param 'blue';
Exception happened!

@@ not_found.html.ep
% title 'Not found happened';
% layout 'green' if param 'green';
% extends 'blue' if param 'blue';
Not found happened!

@@ template_inheritance.html.ep
% layout 'template_inheritance';
% title 'Works!';
<% content header => begin =%>
<%= b('<br>') %>
<% end =%>
<% content sidebar => begin =%>
Sidebar!
<% end =%>
Hello World!

@@ layouts/template_inheritance.html.ep
<title><%= title %></title>
% stash foo => 'Default';



( run in 0.920 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )