/** * Dump block node to string. * * @param BlockNode $node block node * @param integer $level indentation level * * @return string */ protected function dumpBlock(BlockNode $node, $level = 0) { $html = ''; $last = ''; $childs = $node->getChilds(); foreach ($childs as $i => $child) { if (!empty($html) && !empty($last)) { $html .= "\n"; } $this->nextExtendsIf[$level] = isset($childs[$i + 1]) && $childs[$i + 1] instanceof CodeNode && preg_match($this->nextExtendsIfRegexp, $childs[$i + 1]->getCode()); $last = $this->dumpNode($child, $level); $html .= $last; } return $html; }
/** * Initialize tag node. * * @param string $name tag name * @param integer $line source line */ public function __construct($name, $line) { parent::__construct($line); $this->name = $name; }
/** * Creates a new with block helper * * @param string[] $options * @param com.github.mustache.NodeList $fn * @param com.github.mustache.NodeList $inverse * @param string $start * @param string $end */ public function __construct($options = [], NodeList $fn = null, NodeList $inverse = null, $start = '{{', $end = '}}') { parent::__construct('with', $options, $fn, $inverse, $start, $end); }
/** * Parse indented block token. * * @return BlockNode */ protected function parseBlock() { $node = new BlockNode($this->lexer->getCurrentLine()); $this->expectTokenType('indent'); while ('outdent' !== $this->lexer->predictToken()->type) { if ('newline' === $this->lexer->predictToken()->type) { $this->lexer->getAdvancedToken(); } else { $node->addChild($this->parseExpression()); } } $this->expectTokenType('outdent'); return $node; }