From: John Napiorkowski Date: Fri, 1 Oct 2010 01:41:31 +0000 (-0400) Subject: added more docs X-Git-Tag: release_0.009004~21 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FHTML-Zoom.git;a=commitdiff_plain;h=434a11c88e94485345f846ced10473103adba4a4 added more docs --- diff --git a/lib/HTML/Zoom/FilterBuilder.pm b/lib/HTML/Zoom/FilterBuilder.pm index 58237ca..6bbaa04 100644 --- a/lib/HTML/Zoom/FilterBuilder.pm +++ b/lib/HTML/Zoom/FilterBuilder.pm @@ -314,6 +314,14 @@ HTML::Zoom::FilterBuilder - Add Filters to a Stream ->replace_content($body) ->then ->set_attribute(class=>'main') + ->then + ->add_to_attribute(class=>'one-column') + ->then + ->set_attribute(id=>'top') + ->then + ->add_to_attribute(id=>'deleteme') + ->then + ->remove_attribute({name=>'id'}) ->select('p') ->set_attribute(class=>'para') ->select('#p2') @@ -332,7 +340,7 @@ will produce: Hello World -
+

Well Now

Is the Time

@@ -355,7 +363,7 @@ alter the content of that stream. This class defines the following public API -=head2 set_attribute +=head2 set_attribute ( $attr=>value | {name=>$attr,value=>$value} ) Sets an attribute of a given name to a given value for all matching selections. @@ -363,19 +371,37 @@ Sets an attribute of a given name to a given value for all matching selections. ->select('p') ->set_attribute(class=>'paragraph') ->select('div') - ->set_attribute(name=>'class', value=>'divider') + ->set_attribute(name=>'class', value=>'divider'); + Overrides existing values, if such exist. When multiple L calls are made against the same or overlapping selection sets, the final call wins. -=head2 add_to_attribute +=head2 add_to_attribute ( $attr=>value | {name=>$attr,value=>$value} ) - TBD +Adds a value to an existing attribute, or creates one if the attribute does not +yet exist. -=head2 remove_attribute + $html_zoom + ->select('p') + ->set_attribute(class=>'paragraph') + ->then + ->add_to_attribute(name=>'class', value=>'divider'); - TBD +Attributes with more than one value will have a dividing space. + +=head2 remove_attribute ( $attr | {name=>$attr} ) + +Removes an attribute and all its values. + + $html_zoom + ->select('p') + ->set_attribute(class=>'paragraph') + ->then + ->remove_attribute('class'); + +Removes attributes from the original stream or events already added. =head2 collect diff --git a/t/synopsis/filterbuilder.t b/t/synopsis/filterbuilder.t index 9fc9f41..67083c6 100644 --- a/t/synopsis/filterbuilder.t +++ b/t/synopsis/filterbuilder.t @@ -30,6 +30,14 @@ my $output = $root ->replace_content($body) ->then ->set_attribute(class=>'main') + ->then + ->add_to_attribute(class=>'one-column') + ->then + ->set_attribute(id=>'top') + ->then + ->add_to_attribute(id=>'deleteme') + ->then + ->remove_attribute({name=>'id', value=>'deleteme'}) ->select('p') ->set_attribute(class=>'para') ->select('#p2') @@ -42,7 +50,7 @@ my $expect = < Hello World -
+

Well Now

Is the Time