2 use warnings FATAL => 'all';
7 ok my $zoom = HTML::Zoom->from_html(<<HTML);
12 <body id="content-area">
15 <p class="first-para">Some Stuff</p>
16 <p class="body-para">More Stuff</p>
17 <p class="body-para">Even More Stuff</p>
19 <li class="first-item odd">First</li>
20 <li class="body-items even">Stuff A</li>
21 <li class="body-items odd">Stuff B</li>
22 <li class="body-items even">Stuff C</li>
23 <li class="last-item odd">Last</li>
26 <li class="first">space</li>
27 <li class="second">space</li>
29 <p class="body-para">Even More stuff</p>
30 <p class="last-para">Some Stuff</p>
33 <h2 class="h2-item">Sub Item</h2>
36 <li class="name">name</li>
37 <li class="email">email</li>
40 <li class="name">name</li>
41 <li class="email">email</li>
44 <li class="aa">AA</li>
45 <li class="bb">BB</li>
47 <p id="footer">Copyright 2222</p>
52 ## Stub for testing the fill method to be
55 my ($z, $content) = @_;
56 $z = $z->select('title')->replace_content($content);
62 ->from_html(q[<ul><li>Test</li></ul>])
66 sub { $_->select('li')->replace_content('Real Life1') },
67 sub { $_->select('li')->replace_content('Real Life2') },
68 sub { $_->select('li')->replace_content('Real Life3') },
73 is $z, '<ul><li>Real Life1</li><li>Real Life2</li><li>Real Life3</li></ul>',
74 'Got correct from repeat_content';
79 ->from_html(q[<ul><li>Test</li></ul>])
82 map { my $i = $_; +sub {$_->select('li')->replace_content("Real Life$i")} } (1,2,3)
86 is $z, '<ul><li>Real Life1</li><li>Real Life2</li><li>Real Life3</li></ul>',
87 'Got correct from repeat_content';
91 use HTML::Zoom::CodeStream;
95 HTML::Zoom::CodeStream->new({
102 my @list = qw(foo bar baz);
103 ok my $z = HTML::Zoom
104 ->from_html(q[<ul><li>Test</li></ul>])
106 ->repeat_content(code_stream {
107 if (my $name = shift @list) {
108 return sub { $_->select('li')->replace_content($name) };
115 is $z, '<ul><li>foo</li><li>bar</li><li>baz</li></ul>',
116 'Got correct from repeat_content';
120 my @list = qw(foo bar baz);
121 ok my $z = HTML::Zoom
122 ->from_html(q[<ul><li>Test</li></ul>])
124 ->repeat_content(sub {
125 HTML::Zoom::CodeStream->new({
127 if (my $name = shift @list) {
128 return sub { $_->select('li')->replace_content($name) };
137 is $z, '<ul><li>foo</li><li>bar</li><li>baz</li></ul>',
138 'Got correct from repeat_content';