Add parent reference to Template instances

This commit is contained in:
Kijin Sung 2023-10-22 00:46:58 +09:00
parent 4054dec926
commit a5d6a76cf4
3 changed files with 57 additions and 18 deletions

View file

@ -407,7 +407,7 @@ class TemplateParser_v2
// Generate the code to create a new Template object and compile it.
$tpl = '<?php $__tpl = new \Rhymix\Framework\Template(' . $dir . ', "' . $path . '", "' . ($this->template->extension ?: 'auto') . '"); ';
$tpl .= 'if ($this->vars): $__tpl->setVars($this->vars); endif; ';
$tpl .= '$__tpl->setParent($this); if ($this->vars): $__tpl->setVars($this->vars); endif; ';
$tpl .= !empty($attrs['vars']) ? '$__tpl->addVars(' . self::_convertVariableScope($attrs['vars']) . '); ' : '';
$tpl .= 'echo $__tpl->compile(); ?>';