Latte\Macros\BlockMacros::macroInclude PHP Method

macroInclude() public method

{include block}
public macroInclude ( MacroNode $node, PhpWriter $writer )
$node Latte\MacroNode
$writer Latte\PhpWriter
    public function macroInclude(MacroNode $node, PhpWriter $writer)
    {
        $node->replaced = FALSE;
        $destination = $node->tokenizer->fetchWord();
        // destination [,] [params]
        if (!preg_match('~#|[\\w-]+\\z~A', $destination)) {
            return FALSE;
        }
        $destination = ltrim($destination, '#');
        $parent = $destination === 'parent';
        if ($destination === 'parent' || $destination === 'this') {
            for ($item = $node->parentNode; $item && $item->name !== 'block' && !isset($item->data->name); $item = $item->parentNode) {
            }
            if (!$item) {
                throw new CompileException("Cannot include {$destination} block outside of any block.");
            }
            $destination = $item->data->name;
        }
        $noEscape = Helpers::removeFilter($node->modifiers, 'noescape');
        if (!$noEscape && Helpers::removeFilter($node->modifiers, 'escape')) {
            trigger_error('Macro ' . $node->getNotation() . ' provides auto-escaping, remove |escape.');
        }
        if ($node->modifiers && !$noEscape) {
            $node->modifiers .= '|escape';
        }
        return $writer->write('$this->renderBlock' . ($parent ? 'Parent' : '') . '(' . (strpos($destination, '$') === FALSE ? var_export($destination, TRUE) : $destination) . ', %node.array? + ' . (isset($this->namedBlocks[$destination]) || $parent ? 'get_defined_vars()' : '$this->params') . ($node->modifiers ? ', function ($s, $type) { $_fi = new LR\\FilterInfo($type); return %modifyContent($s); }' : ($noEscape || $parent ? '' : ', ' . var_export(implode($node->context), TRUE))) . ');');
    }