Fix #75: macros don's share between child and parent templates

This commit is contained in:
Ivan Shalganov 2014-04-09 20:01:20 +04:00
parent 1f9a56500e
commit e9a60041c4
2 changed files with 5 additions and 1 deletions

View File

@ -517,6 +517,7 @@ class Compiler
$t->_extended = true;
$tpl->addDepend($t);
$t->_compatible = & $tpl->_compatible;
$t->macros = & $tpl->macros;
$t->blocks = & $tpl->blocks;
$t->compile();
if ($t->uses) {

View File

@ -1254,6 +1254,7 @@ class Template extends Render
$macro = false;
if (isset($this->macros[$name])) {
$macro = $this->macros[$name];
$recursive = $macro['recursive'];
} else {
foreach ($this->_stack as $scope) {
if ($scope->name == 'macro' && $scope['name'] == $name) { // invoke recursive
@ -1280,8 +1281,10 @@ class Template extends Render
}
$n = sprintf('%u_%d', crc32($this->_name), $this->i++);
if ($recursive) {
$recursive['recursive'] = true;
$body = '$tpl->getMacro("' . $name . '")->__invoke($tpl);';
if($recursive instanceof Scope) {
$recursive['recursive'] = true;
}
} else {
$body = '?>' . $macro["body"] . '<?php';
}