public function macroBlockEnd(MacroNode $node, PhpWriter $writer)
{
if (isset($node->data->name)) {
// block, snippet, define
if ($asInner = $node->name === 'snippet' && $node->prefix === MacroNode::PREFIX_NONE) {
$node->content = $node->innerContent;
}
if (($node->name === 'snippet' || $node->name === 'snippetArea') && strpos($node->data->name, '$') === FALSE) {
$type = $node->name === 'snippet' ? SnippetDriver::TYPE_STATIC : SnippetDriver::TYPE_AREA;
$node->content = '<?php $this->global->snippetDriver->enter(' . $writer->formatWord(substr($node->data->name, 1)) . ', "' . $type . '"); ?>' . preg_replace('#(?<=\\n)[ \\t]+\\z#', '', $node->content) . '<?php $this->global->snippetDriver->leave(); ?>';
}
if (empty($node->data->leave)) {
if (preg_match('#\\$|n:#', $node->content)) {
$node->content = '<?php ' . (isset($node->data->args) ? 'extract($this->params); ' . $node->data->args : 'extract($_args);') . ' ?>' . $node->content;
}
$this->namedBlocks[$node->data->name] = $tmp = preg_replace('#^\\n+|(?<=\\n)[ \\t]+\\z#', '', $node->content);
$node->content = substr_replace($node->content, $node->openingCode . "\n", strspn($node->content, "\n"), strlen($tmp));
$node->openingCode = '<?php ?>';
} elseif (isset($node->data->func)) {
$node->content = rtrim($node->content, " \t");
$this->getCompiler()->addMethod($node->data->func, $this->getCompiler()->expandTokens("extract(\$_args);\n?>{$node->content}<?php"), '$_args');
$node->content = '';
}
if ($asInner) {
// n:snippet -> n:inner-snippet
$node->innerContent = $node->openingCode . $node->content . $node->closingCode;
$node->closingCode = $node->openingCode = '<?php ?>';
}
return ' ';
// consume next new line
} elseif ($node->modifiers) {
// anonymous block with modifier
$node->modifiers .= '|escape';
return $writer->write('$_fi = new LR\\FilterInfo(%var); echo %modifyContent(ob_get_clean());', $node->context[0]);
}
}