mirror of
https://github.com/smarty-php/smarty.git
synced 2026-05-05 04:04:10 +02:00
- improvement new Smarty::$extends_recursion property to disable execution of {extends} in templates called by extends resource
https://github.com/smarty-php/smarty/issues/296
This commit is contained in:
@@ -99,14 +99,22 @@ class Smarty_Internal_Runtime_Inheritance
|
||||
* End of child template(s)
|
||||
* - if outer level is reached flush output buffer and switch to wait for parent template state
|
||||
*
|
||||
* @param \Smarty_Internal_Template $tpl
|
||||
* @param null|string $template optinal name of inheritance parent template
|
||||
* @param null|string $uid uid of inline template
|
||||
* @param null|string $func function call name of inline template
|
||||
*/
|
||||
public function endChild()
|
||||
public function endChild(Smarty_Internal_Template $tpl, $template = null, $uid = null, $func = null)
|
||||
{
|
||||
$this->inheritanceLevel --;
|
||||
if (!$this->inheritanceLevel) {
|
||||
ob_end_clean();
|
||||
$this->state = 2;
|
||||
}
|
||||
if (isset($template) && ($tpl->parent->source->type !== 'extends' || $tpl->smarty->extends_recursion)) {
|
||||
$tpl->_subTemplateRender($template, $tpl->cache_id, $tpl->compile_id, $tpl->caching ? 9999 : 0,
|
||||
$tpl->cache_lifetime, array(), 2, false, $uid, $func);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -197,11 +205,22 @@ class Smarty_Internal_Runtime_Inheritance
|
||||
* @param \Smarty_Internal_Template $tpl
|
||||
* @param \Smarty_Internal_Block $block
|
||||
*
|
||||
* @param null $name
|
||||
*
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function callParent(Smarty_Internal_Template $tpl, Smarty_Internal_Block $block)
|
||||
public function callParent(Smarty_Internal_Template $tpl, Smarty_Internal_Block $block, $name = null)
|
||||
{
|
||||
if (isset($block->parent)) {
|
||||
if (isset($name)) {
|
||||
$block = $block->parent;
|
||||
while (isset($block)) {
|
||||
if (isset($block->subBlocks[ $name ])) {
|
||||
} else {
|
||||
$block = $block->parent;
|
||||
}
|
||||
}
|
||||
return;
|
||||
} else if (isset($block->parent)) {
|
||||
$this->callBlock($block->parent, $tpl);
|
||||
} else {
|
||||
throw new SmartyException("inheritance: illegal {\$smarty.block.parent} or {block append/prepend} used in parent template '{$tpl->inheritance->sources[$block->tplIndex]->filepath}' block '{$block->name}'");
|
||||
|
||||
Reference in New Issue
Block a user