]> iEval git - html-element-library.git/blobdiff - lib/HTML/Element/Library.pm
new content_handler functionality
[html-element-library.git] / lib / HTML / Element / Library.pm
index 523c2111b8cc3987f0bf5a12000bf61dfd5666bd..99abc3d39f7c534ce6eff10ac7cbba1cbedcbbeb 100644 (file)
@@ -39,18 +39,13 @@ sub HTML::Element::siblings {
 sub HTML::Element::passover {
   my ($tree, $child_id) = @_;
   
-  #warn "ARGS:   my ($tree, $child)";
+  warn "ARGS:   my ($tree, $child_id)";
 
   my $exodus = $tree->look_down(id => $child_id);
 
   my @s = HTML::Element::siblings($exodus);
 
-  warn "sibling count", scalar @s;
-  warn "siblings", join ':', @s;
-
   for my $s (@s) {
-    warn "SIBLING: $s";
-    warn "ref sib", ref $s;
     next unless ref $s;
     if ($s->attr('id') eq $child_id) {
       ;
@@ -116,9 +111,12 @@ sub HTML::Element::position {
 
 
 sub HTML::Element::content_handler {
-  my ($tree, $id_name, $content) = @_;
+  my ($tree, %content_hash) = @_;
+
+  for my $k (keys %content_hash) {
+      $tree->set_child_content(id => $k, $content_hash{$k});      
+  }
 
-  $tree->set_child_content(id => $id_name, $content);
 
 }
 
@@ -557,9 +555,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}) ;
 
@@ -598,12 +596,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;
   }
@@ -742,7 +740,7 @@ happens to be a non-element, a push_content is performed instead.
 
 After finding the node, it detaches the node's content and pushes $content as the node's content.
 
-=head3 $tree->content_handler($sid_value , $content)
+=head3 $tree->content_handler(%id_content)
 
 This is a convenience method. Because the look_down criteria will often simply be:
 
@@ -760,6 +758,15 @@ Instead of typing:
 
   $elem->set_child_content(sid => 'fixme', 'new text') 
 
+PLEASE NOTE: you can pass a hash whose keys are C<id>s and whose values are the content you want there and it will perform the replacement on each hash member:
+
+  my %id_content = (name => "Terrence Brannon",      
+                    email => 'tbrannon@in.com',
+                    balance => 666,                         
+                    content => $main_content);             
+
+  $tree->content_handler(%id_content);  
+
 =head3 $tree->highlander($subtree_span_id, $conditionals, @conditionals_args)
 
 This allows for "if-then-else" style processing. Highlander was a movie in
@@ -805,6 +812,14 @@ id C<under10> remains. For age less than 18, the node with id C<under18>
 remains.
 Otherwise our "else" condition fires and the child with id C<welcome> 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<passover> to remove it's siblings. For the HTML
+above, you could delete C<under10> and C<welcome> by simply calling:
+
+  $tree->passover('under18');
+
 =head3 $tree->highlander2($tree, $conditionals, @conditionals_args)
 
 Right around the same time that C<table2()> came into being, Seamstress
This page took 0.027955 seconds and 4 git commands to generate.