Beispiel #1
0
 /**
  * Parse next filter token. 
  * 
  * @return  FilterNode
  */
 protected function parseFilter()
 {
     $block = null;
     $token = $this->expectTokenType('filter');
     $attributes = $this->acceptTokenType('attributes');
     if ('text' === $this->lexer->predictToken(2)->type) {
         $block = $this->parseTextBlock();
     } else {
         $block = $this->parseBlock();
     }
     $node = new FilterNode($token->value, null !== $attributes ? $attributes->attributes : array(), $this->lexer->getCurrentLine());
     $node->setBlock($block);
     return $node;
 }
Beispiel #2
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));
 }