sub collect {
my ($self, $options) = @_;
- my ($into, $passthrough, $content) = @{$options}{qw(into passthrough content)};
+ my ($into, $passthrough, $content, $filter) =
+ @{$options}{qw(into passthrough content filter)};
sub {
my ($evt, $stream) = @_;
# We wipe the contents of @$into here so that other actions depending
my $name = $evt->{name};
my $depth = 1;
my $_next = $content ? 'peek' : 'next';
+ $stream = $filter->($stream) if $filter;
my $collector = $self->_stream_from_code(sub {
return unless $stream;
while (my ($evt) = $stream->$_next) {
'repeat_content ok'
);
+is(
+ run_for {
+ my @between;
+ $_->repeat_content(
+ [
+ sub {
+ HTML::Zoom::CodeStream->from_array(
+ (filter
+ filter($_ => '.name' => $r_content->('mst'))
+ => '.career' => $r_content->('Chainsaw Wielder')),
+ HTML::Zoom::CodeStream->from_array(@between)
+ )->flatten
+ },
+ sub {
+ filter
+ filter($_ => '.name' => $r_content->('mdk'))
+ => '.career' => $r_content->('Adminion')
+ },
+ ],
+ { filter => sub {
+ filter $_[0] => 'hr' => sub { $_->collect({ into => \@between }) }
+ }
+ }
+ )
+ },
+ q{<body>
+ <div class="main">
+ <span class="hilight name">mst</span>
+ <span class="career">Chainsaw Wielder</span>
+ <hr />
+ <span class="hilight name">mdk</span>
+ <span class="career">Adminion</span>
+
+ </div>
+</body>
+},
+ 'repeat_content with filter ok'
+);
+
done_testing;