diff options
author | Matt Farina <[email protected]> | 2013-05-27 17:38:02 -0400 |
---|---|---|
committer | Matt Farina <[email protected]> | 2013-05-27 17:38:02 -0400 |
commit | 0e7cd49d390160603563c17c76dea82eba1824b9 (patch) | |
tree | beae415abb00ddcaa025d5b93aff793c5dfd8b07 /src/HTML5/Serializer/Serializer.php | |
parent | 3f7e489e0eab9b34d6c707d13726eaa195bef2eb (diff) |
Seperated the Traverser from the Output generation.
The Traverser now simply walks through a document. The OutputRules convert
the nodes into output html. The rules is a configurable options. By default
OutputRules will generate html close to the html5 that was parsed. Alternate
rule implementation (e.g., minify rules, pretty spacing rules) can be set
as the default or on an individual case.
Diffstat (limited to 'src/HTML5/Serializer/Serializer.php')
-rw-r--r-- | src/HTML5/Serializer/Serializer.php | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/src/HTML5/Serializer/Serializer.php b/src/HTML5/Serializer/Serializer.php index 3f9187f..7053df5 100644 --- a/src/HTML5/Serializer/Serializer.php +++ b/src/HTML5/Serializer/Serializer.php @@ -15,8 +15,7 @@ namespace HTML5\Serializer; */ class Serializer { protected $dom; - protected $pretty = TRUE; - protected $encode = FALSE; + protected $options = array(); /** * Create a serializer. @@ -36,14 +35,7 @@ class Serializer { */ public function __construct($dom, $options = array()) { $this->dom = $dom; - - if (isset($options['format']) && is_bool($options['format'])) { - $this->pretty = $options['format']; - } - - if (isset($options['encode']) && is_bool($options['encode'])) { - $this->encode = $options['encode']; - } + $this->options = $options; } /** @@ -63,9 +55,7 @@ class Serializer { else { $file = fopen($filename, 'w'); } - $trav = new Traverser($this->dom, $file); - $trav->formatOutput($this->pretty); - $trav->encodeOutput($this->encode); + $trav = new Traverser($this->dom, $file, $this->options); $trav->walk(); |