X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FHTML%2FZoom%2FFilterBuilder.pm;h=32ffe115b136cf8c79be978992f0d74569181d19;hb=a88c1c57d4d91cc32c4cdf779a1b737482244322;hp=6b50bbb022bf3d6032c68703be6aceea4c015947;hpb=97192b02d221241de847e9fe853ec6867ee90fd0;p=catagits%2FHTML-Zoom.git diff --git a/lib/HTML/Zoom/FilterBuilder.pm b/lib/HTML/Zoom/FilterBuilder.pm index 6b50bbb..32ffe11 100644 --- a/lib/HTML/Zoom/FilterBuilder.pm +++ b/lib/HTML/Zoom/FilterBuilder.pm @@ -193,6 +193,20 @@ sub replace { my ($evt, $stream) = @_; my $emit = $self->_stream_from_proto($replace_with); my $coll = &$coll_proto; + # if we're replacing the contents of an in place close + # then we need to handle that here + if ($options->{content} + && ref($coll) eq 'HASH' + && delete $coll->{is_in_place_close} + ) { + delete $coll->{raw}; + my $close = $stream->next; + delete @{$close}{qw(is_in_place_close raw)}; + $emit = $self->_stream_concat( + $emit, + $self->_stream_from_array($close), + ); + } # For a straightforward replace operation we can, in fact, do the emit # -before- the collect, and my first cut did so. However in order to # use the captured content in generating the new content, we need @@ -201,9 +215,11 @@ sub replace { # for the difference to be noticeable return ($coll - ? (ref $coll eq 'ARRAY' + ? (ref $coll eq 'ARRAY' # [ event, stream ] ? [ $coll->[0], $self->_stream_concat($coll->[1], $emit) ] - : $self->_stream_concat($coll, $emit) + : (ref $coll eq 'HASH' # event or stream? + ? [ $coll, $emit ] + : $self->_stream_concat($coll, $emit)) ) : $emit );