]> iEval git - html-element-library.git/blob - t/dual_iter.t
hash_map method about to be public for real
[html-element-library.git] / t / dual_iter.t
1 # This might look like shell script, but it's actually -*- perl -*-
2 use strict;
3 use lib qw(t/ t/m/);
4
5 use File::Slurp;
6 use Test::More qw(no_plan);
7
8 use TestUtils;
9 use HTML::TreeBuilder;
10 use HTML::Element::Library;
11
12 # this is a simpler call to iter2()
13
14 my $root = 't/html/dual_iter';
15
16 my $tree = HTML::TreeBuilder->new_from_file("$root.html");
17
18 my $dl = $tree->look_down(id => 'service_plan');
19
20
21 my @items = (
22 ['the pros' => 'never have to worry about service again'],
23 ['the cons' => 'upfront extra charge on purchase'],
24 ['our choice' => 'go with the extended service plan']
25 );
26
27
28 $tree->iter2(
29
30 wrapper_data => \@items,
31
32 wrapper_proc => sub {
33 my ($container) = @_;
34
35 # only keep the last 2 dts and dds
36 my @content_list = $container->content_list;
37 $container->splice_content(0, @content_list - 2);
38 },
39
40
41 splice => sub {
42 my ($container, @item_elems) = @_;
43 $container->unshift_content(@item_elems);
44 },
45
46 debug => 1,
47
48 );
49
50 my $generated_html = ptree($tree, "$root.gen");
51
52 is ($generated_html, File::Slurp::read_file("$root.exp"),
53 "HTML for generated li");
This page took 0.049898 seconds and 4 git commands to generate.