- 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
@@ -117,7 +117,7 @@ class Smarty_Internal_TemplateCompilerBase {
if (($_output = $this->callTagCompiler($tag, $args)) === false) {
if (isset($this->smarty->template_functions[$tag])) {
// template defined by {template} tag
$args['name'] = $tag;
$args['name'] = "'" . $tag . "'";
$_output = $this->callTagCompiler('call', $args);
}
}
@@ -287,29 +287,30 @@ class Smarty_Internal_TemplateCompilerBase {
foreach((array)$this->smarty->plugins_dir as $_plugin_dir) {
$file = rtrim($_plugin_dir, '/\\') . DS . $type . '.' . $plugin_name . '.php';
if (file_exists($file)) {
require_once($file);
// require_once($file);
$found = true;
break;
}
}
if ($found) {
if (is_callable($plugin)) {
$this->template->required_plugins_call[$plugin_name][$type] = $plugin;
if ($this->template->caching && ($this->nocache || $this->tag_nocache)) {
$this->template->required_plugins['cache'][$plugin_name]['file'] = $file;
$this->template->required_plugins['cache'][$plugin_name]['type'] = $type;
} else {
$this->template->required_plugins['compiled'][$plugin_name]['file'] = $file;
$this->template->required_plugins['compiled'][$plugin_name]['type'] = $type;
}
if ($type == 'modifier') {
$this->template->saved_modifer[$plugin_name] = true;
}
return $plugin;
// if (is_callable($plugin)) {
$this->template->required_plugins_call[$plugin_name][$type] = $plugin;
if ($this->template->caching && ($this->nocache || $this->tag_nocache)) {
$this->template->required_plugins['cache'][$plugin_name]['file'] = $file;
$this->template->required_plugins['cache'][$plugin_name]['type'] = $type;
} else {
$this->template->required_plugins['compiled'][$plugin_name]['file'] = $file;
$this->template->required_plugins['compiled'][$plugin_name]['type'] = $type;
}
if ($type == 'modifier') {
$this->template->saved_modifer[$plugin_name] = true;
}
return $plugin;
/* } else {
throw new Exception("Plugin {$type} \"{$plugin_name}\" not callable");
}
*/
}
return false;
}