HamlCommentNode.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /* SVN FILE: $Id: HamlCommentNode.php 49 2010-04-04 10:51:24Z chris.l.yates $ */
  3. /**
  4. * HamlCommentNode 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. /**
  12. * HamlCommentNode class.
  13. * Represents a comment, including MSIE conditional comments.
  14. * @package PHamlP
  15. * @subpackage Haml.tree
  16. */
  17. class HamlCommentNode extends HamlNode {
  18. private $isConditional;
  19. public function __construct($content, $parent) {
  20. $this->content = $content;
  21. $this->isConditional = (bool)preg_match('/^\[.+\]$/', $content, $matches);
  22. $this->parent = $parent;
  23. $this->root = $parent->root;
  24. $parent->children[] = $this;
  25. }
  26. public function getIsConditional() {
  27. return $this->isConditional;
  28. }
  29. public function render() {
  30. $output = $this->renderer->renderOpenComment($this);
  31. foreach ($this->children as $child) {
  32. $output .= $child->render();
  33. } // foreach
  34. $output .= $this->renderer->renderCloseComment($this);
  35. return $this->debug($output);
  36. }
  37. }