HTML::ElementSuper(3pm) | User Contributed Perl Documentation | HTML::ElementSuper(3pm) |
HTML::ElementSuper - Perl extension for HTML::Element(3)
use HTML::ElementSuper; ### Positional extension $e = new HTML::ElementSuper 'font'; $sibling_number = $e->addr(); $e2 = new HTML::ElementSuper 'p'; $e2->push_content($e); # @coords = $e->position(); $depth_in_pos_tree = $e->depth(); ### Replacer extension $er = new HTML::ElementSuper 'font'; # Tree beneath $er, if present, is dropped. $er->replace_content(new HTML::Element 'p'); ### Wrapper extension $ew = new HTML::ElementSuper; $ew->push_content("Tickle me, baby"); $ew->wrap_content(new HTML::Element 'font', color => 'pink'); print $ew->as_HTML(); ### Maskable extension $em = new HTML::ElementSuper 'td'; $em->mask(1); print $em->as_HTML; # nada $em->mask(0); print $em->as_HTML; # $e and its children are visible ### Cloning of own tree or another element's tree ### (is this the correct clomenature? :-) $a = new HTML::ElementSuper 'font', size => 2; $b = new HTML::ElementSuper 'font', color => 'red'; $a_clone = $a->clone; $b_clone = $a->clone($b); # Multiple elements can be cloned @clone_clones = $a_clone->clone($a_clone, $b_clone);
HTML::ElementSuper is an extension for HTML::Element(3) that provides several new methods to assist in element manipulation. An HTML::ElementSuper has the following additional properties:
* report is coordinate position in a tree of its peers * replace its contents * wrap its contents in a new element * mask itself so that it and its descendants are invisible to traverse() * clone itself and other HTML::Element based object trees * handle multiple values for attributes
Note that these extensions were originally developed to assist in implementing the HTML::ElementTable(3) class, but were thought to be of general enough utility to warrant their own package.
This might seem like a strange method to have, but it helps in managing dynamic tree structures. For example, in HTML::ElementTable(3), when you expand a table cell you simply mask what it covers rather than destroy it. Shrinking the table cell reveals that content to as_HTML() once again.
Matthew P. Sisk, <sisk@mojotoad.com>
Copyright (c) 1998-2010 Matthew P. Sisk. All rights reserved. All wrongs revenged. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
HTML::Element(3), HTML::ElementGlob(3), HTML::ElementRaw(3), HTML::ElementTable(3), perl(1).
2021-01-04 | perl v5.32.0 |