public function testSetIndentationLevelTemplate() { $parentNode = new HamlNode("parent"); $childNode = new HamlNode(" child"); $childNode2 = new HamlNode(" child"); $parentNode->addNode($childNode); $childNode->addNode($childNode2); $parentNode->setIndentationLevel($parentNode->getIndentationLevel() + 2); $output = $parentNode->render(); $this->assertEquals(" parent\n child\n child\n", $output); }
public function filter(HamlNode $node) { if ($node === null) { throw new Exception('PHP filter: node is null'); } $plainFilter = new PlainFilter(); $output = $node->getSpaces() . "<?php\n"; $output .= $plainFilter->filter($node); $output .= $node->getSpaces() . "?>"; return $output . "\n"; }
public function filter(HamlNode $node) { if (null === $node) { throw new Exception("CssFilter: node is null."); } $plainFilter = new PlainFilter(); $output = $node->getSpaces() . "<style type=\"text/css\">\n"; $oldLevel = $node->getIndentationLevel(); $node->setIndentationLevel($oldLevel + 2); $output .= $plainFilter->filter($node); $node->setIndentationLevel($oldLevel); $output .= $node->getSpaces() . "</style>"; return $output . "\n"; }
public function filter(HamlNode $node) { if ($node === null) { throw new Exception('Javascript filter: node is null'); } $plainFilter = new PlainFilter(); $output = $node->getSpaces() . "<script type=\"text/javascript\">\n"; $oldLevel = $node->getIndentationLevel(); $node->setIndentationLevel($oldLevel + 2); $output .= $plainFilter->filter($node); $node->setIndentationLevel($oldLevel); $output .= $node->getSpaces() . "</script>"; return $output . "\n"; }
public function __construct($line, $compiler) { parent::__construct($line); $this->_phpVariable = false; $this->_el = new Element($this->getHaml(), $compiler); $this->_phpVariable = $this->_el->isPhpVariable(); }
public function __construct($line) { parent::__construct($line); $parts = explode(' ', trim($line)); $this->_type = isset($parts[1]) ? strtolower($parts[1]) : ''; if ('xml' == $this->_type && isset($parts[2])) { $this->_encoding = $parts[2]; } }
/** * @see IFilter::filter() */ public function filter(HamlNode $node) { if (null === $node) { throw new Exception("MarkdownFilter: node is null."); } $children = $node->getChildren(); $output = ''; $indent = 999999999; // gets the lowes indent among the children to set as base foreach ($children as $child) { if ($indent > ($ind = $child->getIndentationLevel())) { $indent = $ind; } } foreach ($children as $childNode) { $output .= substr($childNode->getRawHaml(), $indent) . "\n"; } return $this->parser->transform($output); }
protected function renderChildrenHaml(HamlNode $node) { $parent = $node->getParent(); $haml = $parent !== null ? $parent->getSpaces() . $node->getHaml() : $node->getRawHaml(); $output = $haml . "\n"; if ($node->hasChildren()) { $children = $node->getChildren(); for ($i = 0, $count = count($children); $i < $count; ++$i) { $output .= $this->renderChildrenHaml($children[$i]); } } return $output; }
public function __construct($line) { parent::__construct($line); $this->_line = $line; if (!preg_match(TagNode::CODE_PATTERN, $this->_line, $matches)) { throw new InvalidTagException('Line does not match the pattern'); } $this->_mode = $matches['mode']; $this->_code = $matches['code']; if (isset($matches['tag'])) { $tag = trim($matches['tag']); if (isset($this->_tags[$tag])) { $this->_isTag = true; $this->_tag = $tag; if (!isset($matches['colon'])) { $this->_code .= ':'; } } } if ($this->_isTag && TagNode::LOUD_MODE == $this->_mode) { throw new InvalidTagException('Loud mode is not allowed for the tags ' . join(', ', array_keys($this->_tags)) . '. Use silent mode (-).'); } }
public function __construct($line, FilterContainer $container = null) { parent::__construct($line); $this->_filterContainer = $container; }
public function __construct($line) { parent::__construct($line); $this->identifyCommentType(); }