while (my ($evt) = $stream->next) {
$depth++ if ($evt->{type} eq 'OPEN');
$depth-- if ($evt->{type} eq 'CLOSE');
+ push(@$into, $evt) if $into;
unless ($depth) {
undef $stream;
return $evt if $passthrough;
return;
}
- push(@$into, $evt) if $into;
return $evt if $passthrough;
}
die "Never saw closing </${name}> before end of source";
return $html;
}
+sub html_from_events {
+ my ($class, $events) = @_;
+ join '', map $class->_event_to_html($_), @$events;
+}
+
sub _event_to_html {
my ($self, $evt) = @_;
# big expression
'replace ok'
);
+my @ev;
+
+is(
+ run_for { $_->collect({ into => \@ev }) },
+ '<body>
+
+</body>
+',
+ 'collect removes without passthrough'
+);
+
+is(
+ HTML::Zoom::Producer::BuiltIn->html_from_events(\@ev),
+ '<div class="main">
+ <span class="hilight name">Bob</span>
+ <span class="career">Builder</span>
+ <hr />
+ </div>',
+ 'collect collected right events'
+);
done_testing;