Showing an array



examples/dancer/show_array/app.psgi
package App;
use Dancer2;

set 'template'     => 'template_toolkit';

get '/' => sub {
    my @planets = ('Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn');
    return template 'page', { planets => \@planets };
};

App->to_app;

examples/dancer/show_array/views/page.tt
<h1>Planets</h1>
<ul>
 [% FOR planet IN planets -%]
   <li>[% planet %]</li>
  [% END -%]
</ul>

examples/dancer/show_array/test.t
use strict;
use warnings;

use Test::More;
use Plack::Test;
use Plack::Util;
use HTTP::Request::Common;

my $app = Plack::Util::load_psgi './app.psgi';

my $test = Plack::Test->create($app);
my $res = $test->request(GET '/');

is $res->status_line, '200 OK', 'Status';
like $res->content, qr{<h1>Planets</h1>};
like $res->content, qr{<li>Mercury</li>};

done_testing();