]>
Commit | Line | Data |
---|---|---|
67e78ff2 | 1 | # This might look like shell script, but it's actually -*- perl -*- |
2 | use strict; | |
3 | use lib qw(t/ t/m/); | |
4 | ||
5 | ||
6 | use File::Slurp; | |
7 | use Test::More qw(no_plan); | |
8 | ||
9 | use TestUtils; | |
10 | use HTML::TreeBuilder; | |
11 | use HTML::Element::Library; | |
12 | ||
13 | my $root = 't/html/iter2'; | |
14 | ||
15 | my $tree = HTML::TreeBuilder->new_from_file("$root.html"); | |
16 | ||
17 | my @items = ( | |
18 | [ Programmer => 'one who likes Perl and Seamstress', ], | |
19 | [ DBA => 'one who does business as', ], | |
20 | [ Admin => 'one who plays Tetris all day' ] | |
21 | ); | |
22 | ||
23 | $tree->iter2( | |
24 | # default wrapper_ld ok | |
25 | wrapper_data => \@items, | |
26 | wrapper_proc => sub { | |
27 | my ($container) = @_; | |
28 | ||
29 | # only keep the last 2 dts and dds | |
30 | my @content_list = $container->content_list; | |
31 | $container->splice_content(0, @content_list - 2); | |
32 | }, | |
33 | # default item_ld is k00l | |
34 | # default item_data is phrEsh | |
35 | # default item_proc will do w0rk | |
36 | splice => sub { | |
37 | my ($container, @item_elems) = @_; | |
38 | $container->unshift_content(@item_elems); | |
39 | }, | |
40 | ||
41 | debug => 1, | |
42 | ); | |
43 | ||
44 | ||
45 | my $generated_html = ptree($tree, "$root.gen"); | |
46 | ||
47 | is ($generated_html, File::Slurp::read_file("$root.exp"), | |
48 | "HTML for generated li"); |