/** * Post compile action for {extends ...} tag * @param Template $tpl * @param string $body */ public static function extendBody($tpl, &$body) { if ($tpl->dynamic_extends) { if (!$tpl->ext_stack) { $tpl->ext_stack[] = $tpl->getName(); } foreach ($tpl->ext_stack as &$t) { $stack[] = "'{$t}'"; } $stack[] = $tpl->dynamic_extends; $body = '<?php $tpl->getStorage()->display(array(' . implode(', ', $stack) . '), $var); ?>'; } else { $child = $tpl; while ($child && $child->extends) { $parent = $tpl->extend($child->extends); $child = $parent->extends ? $parent : false; } $tpl->extends = false; } $tpl->extend_body = false; }