});
});
};
+
+ ## fill a selection from an array of targets, using a list. Syntax is a bit
+ ## like DBIC->populate
{
ok my $z = HTML::Zoom
'Got correct from repeat_content'
);
}
-
+
+ ## Same as above but using an iterator coderef instead of a pregenerated list
{
my @items = ( [0,1], [2,3] );
ok my $z = HTML::Zoom
);
}
}
+
+ ## Target has a value of a coderef that is expected to take the item from the
+ ## list of data and provide the actual value that goes into the target
{
ok my $z = HTML::Zoom
);
}
}
+
+ ## Like above but showing how this can be used to get a value from any type of
+ ## list item.
{
ok my $z = HTML::Zoom
);
}
}
+
+ ## Just an example of above showing off how you can use Perl to generate the
+ ## needed structures.
{
ok my $even_or_odd = sub {
);
}
}
+
+ ## using a list of objects, we get replace values.
{
{
}
}
+ ## Looks a lot like how pure.js uses 'directives' to map a selector to a value
+ ## from each item in the data list.
+
{
ok my $z = HTML::Zoom
->from_html(q[<ul><li class="even">Even</li><li class="odd">Odd</li></ul>])
}
}
+ ## Ideally the targets are an array so that you properly control the order that
+ ## the replaces happen, but if you don't care you can take advantage of the
+ ## shorthand target structure of a hashref
+
{
ok my $z = HTML::Zoom
->from_html(q[<ul><li class="even">Even</li><li class="odd">Odd</li></ul>])
);
}
}
+
+ ## Using above shortcut with iterator instead of fixed list
+
+ {
+ my @list = (
+ Test::HTML::Zoom::EvenOdd->new(0,1),
+ Test::HTML::Zoom::EvenOdd->new(2,3),
+ );
+
+ ok my $z = HTML::Zoom
+ ->from_html(q[<ul><li class="even">Even</li><li class="odd">Odd</li></ul>])
+ ->select('ul')
+ ->$fill(
+ [qw(even odd)],
+ sub { shift @list },
+ ), 'Made Zoom object from declare accessors style';
+
+ is(
+ $z->to_html,
+ '<ul><li class="even">0</li><li class="odd">1</li><li class="even">2</li><li class="odd">3</li></ul>',
+ 'Got correct from repeat_content',
+ );
+ }
}
done_testing;