Ejemplo n.º 1
0
 /**
  * Dump filter node. 
  * 
  * @param   FilterNode  $node   filter node
  * @param   integer     $level  indentation level
  * 
  * @return  string
  */
 protected function dumpFilter(FilterNode $node, $level = 0)
 {
     if (!isset($this->filters[$node->getName()])) {
         throw new Exception(sprintf('Filter with alias "%s" is not registered.', $node->getName()));
     }
     $text = '';
     if ($node->getBlock()) {
         $text = $this->dumpNode($node->getBlock(), $level + 1);
     }
     return $this->filters[$node->getName()]->filter($text, $node->getAttributes(), str_repeat(' ', $level * $this->options['tabSize']));
 }
Ejemplo n.º 2
0
 /**
  * Parse next filter token. 
  * 
  * @return  FilterNode
  */
 protected function parseFilter()
 {
     $block = null;
     $token = $this->expectTokenType('filter');
     $attributes = $this->acceptTokenType('attributes');
     $block = $this->parseTextBlock();
     $node = new FilterNode($token->value, null !== $attributes ? $attributes->attributes : [], $this->lexer->getCurrentLine());
     $node->setBlock($block);
     return $node;
 }