X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FHTML%2FElement%2FLibrary.pm;h=08f6ee5cf0fa293fd3203880f37938e9cfbde61a;hb=5f53bf212e506831653abc6442b846782211e12c;hp=8f888b5c321384c8cc84a32c52563ff0e82602ce;hpb=67e78ff23a6eddb48860da18de89798a5e3f1efe;p=html-element-library.git diff --git a/lib/HTML/Element/Library.pm b/lib/HTML/Element/Library.pm index 8f888b5..08f6ee5 100644 --- a/lib/HTML/Element/Library.pm +++ b/lib/HTML/Element/Library.pm @@ -24,7 +24,7 @@ our @EXPORT = qw(); -our $VERSION = '3.51'; +our $VERSION = '3.53'; # Preloaded methods go here. @@ -36,6 +36,28 @@ sub HTML::Element::siblings { $p->content_list; } +sub HTML::Element::passover { + my ($tree, $child_id) = @_; + + #warn "ARGS: my ($tree, $child)"; + + my $exodus = $tree->look_down(id => $child_id); + + my @s = HTML::Element::siblings($exodus); + + for my $s (@s) { + next unless ref $s; + if ($s->attr('id') eq $child_id) { + ; + } else { + $s->delete; + } + } + + return $exodus; # Goodbye Egypt! http://en.wikipedia.org/wiki/Passover + +} + sub HTML::Element::sibdex { my $element = shift; @@ -530,9 +552,9 @@ sub HTML::Element::table2 { # ++$DEBUG if $table{debug} ; # Get the table element - warn 1; + #warn 1; $table->{table_node} = ref_or_ld( $tree, $p{table_ld} ) ; - warn 2; + #warn 2; $table->{table_node} or confess "table tag not found via " . Dumper($p{table_ld}) ; @@ -571,12 +593,12 @@ sub HTML::Element::table2 { if defined $p{tr_proc}; warn "data row redux: " . Dumper $row if $p{debug}; - warn 3.3; + #warn 3.3; $p{td_proc}->($new_tr_node, $row); push @table_rows, $new_tr_node; - warn 4.4; + #warn 4.4; redo; } @@ -778,6 +800,14 @@ id C remains. For age less than 18, the node with id C remains. Otherwise our "else" condition fires and the child with id C remains. +=head3 $tree->passover($id_of_element) + +In some cases, you know exactly which element should survive. In this case, +you can simply call C to remove it's siblings. For the HTML +above, you could delete C and C by simply calling: + + $tree->passover('under18'); + =head3 $tree->highlander2($tree, $conditionals, @conditionals_args) Right around the same time that C came into being, Seamstress