- bugfix {extends} with relative file path did not work https://github.com/smarty-php/smarty/issues/154

https://github.com/smarty-php/smarty/issues/158
This commit is contained in:
uwetews
2016-01-27 04:51:02 +01:00
parent 04d9c5cc34
commit f59b00c6dd
5 changed files with 20 additions and 4 deletions

View File

@@ -4,7 +4,9 @@
- bugfix {$smarty.section.customer.loop} did throw compiler error https://github.com/smarty-php/smarty/issues/161 - bugfix {$smarty.section.customer.loop} did throw compiler error https://github.com/smarty-php/smarty/issues/161
update of yesterdays fix update of yesterdays fix
- bugfix string resource could inject code at {block} or inline subtemplates through PHP comments https://github.com/smarty-php/smarty/issues/157 - bugfix string resource could inject code at {block} or inline subtemplates through PHP comments https://github.com/smarty-php/smarty/issues/157
- bugfix output filters did not observe nocache code flag https://github.com/smarty-php/smarty/issues/160 - bugfix output filters did not observe nocache code flhttps://github.com/smarty-php/smarty/issues/154g https://github.com/smarty-php/smarty/issues/160
- bugfix {extends} with relative file path did not work https://github.com/smarty-php/smarty/issues/154
https://github.com/smarty-php/smarty/issues/158
26.01.2016 26.01.2016
- improvement observe Smarty::$_CHARSET in debugging console https://github.com/smarty-php/smarty/issues/169 - improvement observe Smarty::$_CHARSET in debugging console https://github.com/smarty-php/smarty/issues/169

View File

@@ -121,7 +121,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/** /**
* smarty version * smarty version
*/ */
const SMARTY_VERSION = '3.1.30-dev/23'; const SMARTY_VERSION = '3.1.30-dev/24';
/** /**
* define variable scopes * define variable scopes

View File

@@ -200,6 +200,7 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_
if ($compiler->template->compiled->has_nocache_code) { if ($compiler->template->compiled->has_nocache_code) {
$output .= "\$_smarty_tpl->cached->hashes['{$compiler->template->compiled->nocache_hash}'] = true;\n"; $output .= "\$_smarty_tpl->cached->hashes['{$compiler->template->compiled->nocache_hash}'] = true;\n";
} }
$output .= "\$_smarty_tpl->ext->_inheritance->blockNesting++;\n";
if (isset($_assign)) { if (isset($_assign)) {
$output .= "ob_start();\n"; $output .= "ob_start();\n";
} }
@@ -213,6 +214,7 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_
$output .= "\$_smarty_tpl->tpl_vars[{$_assign}] = new Smarty_Variable(ob_get_clean());\n"; $output .= "\$_smarty_tpl->tpl_vars[{$_assign}] = new Smarty_Variable(ob_get_clean());\n";
} }
//$output .= "/*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/\n"; //$output .= "/*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/\n";
$output .= "\$_smarty_tpl->ext->_inheritance->blockNesting--;\n";
$output .= "}\n"; $output .= "}\n";
$output .= "}\n"; $output .= "}\n";
$output .= "/* {/block '{$_name}'} */\n\n"; $output .= "/* {/block '{$_name}'} */\n\n";

View File

@@ -43,7 +43,12 @@ class Smarty_Internal_Resource_File extends Smarty_Resource
) { ) {
throw new SmartyException("Template '{$file}' cannot be relative to template of resource type '{$_template->parent->source->type}'"); throw new SmartyException("Template '{$file}' cannot be relative to template of resource type '{$_template->parent->source->type}'");
} }
// if we are inside an {block} tag the path must be relative to current template
if (isset($_template->ext->_inheritance) && $_template->ext->_inheritance->blockNesting && $_template->parent->parent->_objType == 2) {
$path = dirname($_template->parent->parent->source->filepath) . DS . $file;
} else {
$path = dirname($_template->parent->source->filepath) . DS . $file; $path = dirname($_template->parent->source->filepath) . DS . $file;
}
// normalize path // normalize path
$path = $source->smarty->_realpath($path); $path = $source->smarty->_realpath($path);
// files relative to a template only get one shot // files relative to a template only get one shot

View File

@@ -44,6 +44,13 @@ class Smarty_Internal_Runtime_Inheritance
*/ */
public $tplIndex = - 1; public $tplIndex = - 1;
/**
* current block nesting level
*
* @var int
*/
public $blockNesting = 0;
/** /**
* Array of source template names * Array of source template names
* - key template index * - key template index