/
basic.t
31 lines (25 loc) · 880 Bytes
/
basic.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env perl6
use v6;
use Test;
use Template::Anti :one-off;
my &people = anti-template :source("t/view/basic.html".IO.slurp), -> $at, :$title, :$motto, :@sith-lords {
$at('title, h1')».content($title);
$at('h1')».attr(title => $motto);
$at('ul.people li:not(:first-child)')».remove;
$at('ul.people li:first-child', :one)\
.duplicate(@sith-lords, -> $item, %sith-lord {
my $a = $item.at('a');
$a.content(%sith-lord<name>);
$a.attr(href => %sith-lord<url>);
});
};
my $output = people(
title => 'Sith Lords',
motto => 'The Force shall free me.',
sith-lords => [
{ name => 'Vader', url => 'http://example.com/vader' },
{ name => 'Sidious', url => 'http://example.com/sidious' },
],
);
is "$output\n", "t/basic.out".IO.slurp, 'output is as expected';
done-testing;