Skip to content

Commit

Permalink
- bugfix {extends} with relative file path did not work #154
Browse files Browse the repository at this point in the history
  • Loading branch information
uwetews committed Jan 27, 2016
1 parent 04d9c5c commit f59b00c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
6 changes: 4 additions & 2 deletions change_log.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
- bugfix {$smarty.section.customer.loop} did throw compiler error https://github.com/smarty-php/smarty/issues/161
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 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
- improvement observe Smarty::$_CHARSET in debugging console https://github.com/smarty-php/smarty/issues/169
- bugfix compiling {section} did create warning
Expand Down
2 changes: 1 addition & 1 deletion libs/Smarty.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* smarty version
*/
const SMARTY_VERSION = '3.1.30-dev/23';
const SMARTY_VERSION = '3.1.30-dev/24';

/**
* define variable scopes
Expand Down
2 changes: 2 additions & 0 deletions libs/sysplugins/smarty_internal_compile_block.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $
if ($compiler->template->compiled->has_nocache_code) {
$output .= "\$_smarty_tpl->cached->hashes['{$compiler->template->compiled->nocache_hash}'] = true;\n";
}
$output .= "\$_smarty_tpl->ext->_inheritance->blockNesting++;\n";
if (isset($_assign)) {
$output .= "ob_start();\n";
}
Expand All @@ -213,6 +214,7 @@ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $
$output .= "\$_smarty_tpl->tpl_vars[{$_assign}] = new Smarty_Variable(ob_get_clean());\n";
}
//$output .= "/*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/\n";
$output .= "\$_smarty_tpl->ext->_inheritance->blockNesting--;\n";
$output .= "}\n";
$output .= "}\n";
$output .= "/* {/block '{$_name}'} */\n\n";
Expand Down
7 changes: 6 additions & 1 deletion libs/sysplugins/smarty_internal_resource_file.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ protected function buildFilepath(Smarty_Template_Source $source, Smarty_Internal
) {
throw new SmartyException("Template '{$file}' cannot be relative to template of resource type '{$_template->parent->source->type}'");
}
$path = dirname($_template->parent->source->filepath) . DS . $file;
// 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;
}
// normalize path
$path = $source->smarty->_realpath($path);
// files relative to a template only get one shot
Expand Down
7 changes: 7 additions & 0 deletions libs/sysplugins/smarty_internal_runtime_inheritance.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ class Smarty_Internal_Runtime_Inheritance
*/
public $tplIndex = - 1;

/**
* current block nesting level
*
* @var int
*/
public $blockNesting = 0;

/**
* Array of source template names
* - key template index
Expand Down

0 comments on commit f59b00c

Please sign in to comment.