- optimization of generated code for doublequoted strings containing variables

- rewrite of {function} tag handling
  - can now be declared in an external subtemplate
  - can contain nocache sections (nocache_hash handling)
  - can be called in noccache sections (nocache_hash handling)
  - new {call..} tag to call template functions with a variable name {call name=$foo}
- fixed nocache_hash handling in merged compiled templates
This commit is contained in:
Uwe.Tews
2009-12-31 16:38:12 +00:00
parent a6c4c0b192
commit 72219be200
8 changed files with 141 additions and 70 deletions
+8 -1
View File
@@ -484,6 +484,11 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
if ($this->smarty->debugging) {
Smarty_Internal_Debug::start_cache($this);
}
// dummy renderung because of {function} nocache handling
$_smarty_tpl = $this;
ob_start();
eval("?>" . $this->rendered_content);
ob_get_clean();
// write rendered template
if (!$this->cacheFileWritten) {
$this->writeCachedContent($this);
@@ -495,10 +500,11 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
Smarty_Internal_Debug::end_cache($this);
}
} else {
// var_dump('renderTemplate',$this->has_nocache_code,$this->template_resource, $this->has_nocache_code, $this->properties['nocache_hash'], $this->parent->properties['nocache_hash'], $this->rendered_content);
// var_dump('renderTemplate', $this->has_nocache_code, $this->template_resource, $this->properties['nocache_hash'], $this->parent->properties['nocache_hash'], $this->rendered_content);
if ($this->has_nocache_code && !empty($this->properties['nocache_hash']) && !empty($this->parent->properties['nocache_hash'])) {
// replace nocache_hash
$this->rendered_content = preg_replace("/{$this->properties['nocache_hash']}/", $this->parent->properties['nocache_hash'], $this->rendered_content);
$this->parent->has_nocache_code = $this->has_nocache_code;
}
}
}
@@ -780,6 +786,7 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
$this->properties['file_dependency'] = array_merge($this->properties['file_dependency'], $properties['file_dependency']);
}
if (!empty($properties['function'])) {
$this->properties['function'] = array_merge($this->properties['function'], $properties['function']);
$this->smarty->template_functions = array_merge($this->smarty->template_functions, $properties['function']);
}
}