summaryrefslogtreecommitdiff
path: root/src/HTML5/Serializer.php
diff options
context:
space:
mode:
authorMatt Butcher <[email protected]>2013-04-06 13:35:50 -0500
committerMatt Butcher <[email protected]>2013-04-06 13:35:50 -0500
commitf0aa87d02e8885825878781cd044c04c25e381ea (patch)
treea62dab3ba171f214d38902f557d47337a6713a98 /src/HTML5/Serializer.php
parent87f4c66f006e62789611b2128a90588761395586 (diff)
Converted example.php into a number of unit tests.
Diffstat (limited to 'src/HTML5/Serializer.php')
-rw-r--r--src/HTML5/Serializer.php8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/HTML5/Serializer.php b/src/HTML5/Serializer.php
index e31bbbe..2bed0e8 100644
--- a/src/HTML5/Serializer.php
+++ b/src/HTML5/Serializer.php
@@ -15,6 +15,7 @@ namespace HTML5;
*/
class Serializer {
protected $dom;
+ protected $pretty = TRUE;
/**
* Create a serializer.
@@ -24,9 +25,13 @@ class Serializer {
*
* @param DOMNode $dom
* A DOMNode-like object. Typically, a DOMDocument should be passed.
+ * @param boolean $format
+ * If true, this will format the output (e.g. add indentation). If FALSE, then
+ * little or no formatting will be done.
*/
- public function __construct($dom) {
+ public function __construct($dom, $format = TRUE) {
$this->dom = $dom;
+ $this->pretty = $format;
}
/**
@@ -47,6 +52,7 @@ class Serializer {
$file = fopen($filename, 'w');
}
$trav = new Traverser($this->dom, $file);
+ $trav->formatOutput($this->pretty);
$trav->walk();