trying to make the documentation a little more straightforward to setup
[catagits/HTML-Zoom.git] / t / synopsis / filterbuilder.t
index 9769c3d..1112109 100644 (file)
@@ -2,6 +2,8 @@ use strict;
 use warnings FATAL => 'all';
 use Test::More qw(no_plan);
 
+
+
 use HTML::Zoom;
 my $root = HTML::Zoom
     ->from_html(<<MAIN);
@@ -9,34 +11,66 @@ my $root = HTML::Zoom
   <head>
     <title>Default Title</title>
   </head>
-  <body>
+  <body bad_attr='junk'>
     Default Content
   </body>
 </html>
 MAIN
 
+
+
+$root = $root
+  ->select('body')
+  ->set_attribute(class=>'main');
+
+
+
+$root = $root
+  ->select('body')
+  ->add_to_attribute(class=>'one-column');
+
+
+
+$root = $root
+  ->select('title')
+  ->replace_content('Hello World');
+
+
+
 my $body = HTML::Zoom
     ->from_html(<<BODY);
 <div id="stuff">
-    <p>Stuff</p>
+    <p>Well Now</p>
+    <p id="p2">Is the Time</p>
 </div>
 BODY
 
-my $output =  $root
-->select('title')
-->replace_content('Hello World')
-->select('body')
-->replace_content($body)
-->to_html;
+$root = $root
+  ->select('body')
+  ->replace_content($body);
+
+
+
+$root = $root
+  ->select('p')
+  ->set_attribute(class=>'para');
+
+
+
+$root = $root
+  ->select('body')
+  ->remove_attribute('bad_attr');
 
 
+my $output = $root->to_html;
 my $expect = <<HTML;
 <html>
   <head>
     <title>Hello World</title>
   </head>
-  <body><div id="stuff">
-    <p>Stuff</p>
+  <body class="main one-column"><div id="stuff">
+    <p class="para">Well Now</p>
+    <p id="p2" class="para">Is the Time</p>
 </div>
 </body>
 </html>