HamlRootNode.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /* SVN FILE: $Id: HamlRootNode.php 49 2010-04-04 10:51:24Z chris.l.yates $ */
  3. /**
  4. * HamlRootNode class file.
  5. * @author Chris Yates <chris.l.yates@gmail.com>
  6. * @copyright Copyright (c) 2010 PBM Web Development
  7. * @license http://phamlp.googlecode.com/files/license.txt
  8. * @package PHamlP
  9. * @subpackage Haml.tree
  10. */
  11. require_once(dirname(__FILE__).'/../renderers/HamlRenderer.php');
  12. /**
  13. * HamlRootNode class.
  14. * Also the root node of a document.
  15. * @package PHamlP
  16. * @subpackage Haml.tree
  17. */
  18. class HamlRootNode extends HamlNode {
  19. /**
  20. * @var HamlRenderer the renderer for this node
  21. */
  22. protected $renderer;
  23. /**
  24. * @var array options
  25. */
  26. protected $options;
  27. /**
  28. * Root HamlNode constructor.
  29. * @param array options for the tree
  30. * @return HamlNode
  31. */
  32. public function __construct($options) {
  33. $this->root = $this;
  34. $this->options = $options;
  35. $this->renderer = HamlRenderer::getRenderer($this->options['style'],
  36. array(
  37. 'format' => $this->options['format'],
  38. 'attrWrapper' => $this->options['attrWrapper'],
  39. 'minimizedAttributes' => $this->options['minimizedAttributes'],
  40. )
  41. );
  42. $this->token = array('level' => -1);
  43. }
  44. /**
  45. * Render this node.
  46. * @return string the rendered node
  47. */
  48. public function render() {
  49. foreach ($this->children as $child) {
  50. $this->output .= $child->render();
  51. } // foreach
  52. return $this->output;
  53. }
  54. }