diff --git a/change_log.txt b/change_log.txt index 15f9ddf8..a340d40e 100644 --- a/change_log.txt +++ b/change_log.txt @@ -2,6 +2,8 @@ 01.09.2015 - improvement convert template inheritance into runtime processing - bugfix {$smarty.block.parent} did always reference the root parent block https://github.com/smarty-php/smarty/issues/68 + - move subtemplate code into runtime extension and optimize for size and speed + - move template function code into runtime extension 23.08.2015 - introduce Smarty::$resource_cache_mode and cache template object of {include} inside loop diff --git a/libs/sysplugins/smarty_internal_compile_call.php b/libs/sysplugins/smarty_internal_compile_call.php index 05420fa5..9b1cc585 100644 --- a/libs/sysplugins/smarty_internal_compile_call.php +++ b/libs/sysplugins/smarty_internal_compile_call.php @@ -76,9 +76,9 @@ class Smarty_Internal_Compile_Call extends Smarty_Internal_CompileBase //$compiler->suppressNocacheProcessing = true; // was there an assign attribute if (isset($_assign)) { - $_output = "callTemplateFunction ({$_name}, \$_smarty_tpl, {$_params}, {$_nocache}); \$_smarty_tpl->assign({$_assign}, ob_get_clean());?>\n"; + $_output = "_Function->callTemplateFunction({$_name}, \$_smarty_tpl, {$_params}, {$_nocache});\n\$_smarty_tpl->assign({$_assign}, ob_get_clean());?>\n"; } else { - $_output = "callTemplateFunction ({$_name}, \$_smarty_tpl, {$_params}, {$_nocache});?>\n"; + $_output = "_Function->callTemplateFunction({$_name}, \$_smarty_tpl, {$_params}, {$_nocache});?>\n"; } return $_output; } diff --git a/libs/sysplugins/smarty_internal_runtime_function.php b/libs/sysplugins/smarty_internal_runtime_function.php new file mode 100644 index 00000000..a1f72735 --- /dev/null +++ b/libs/sysplugins/smarty_internal_runtime_function.php @@ -0,0 +1,48 @@ +tpl_function[$name])) { + if (!$_smarty_tpl->caching || ($_smarty_tpl->caching && $nocache)) { + $function = $_smarty_tpl->tpl_function[$name]['call_name']; + } else { + if (isset($_smarty_tpl->tpl_function[$name]['call_name_caching'])) { + $function = $_smarty_tpl->tpl_function[$name]['call_name_caching']; + } else { + $function = $_smarty_tpl->tpl_function[$name]['call_name']; + } + } + if (function_exists($function)) { + $function ($_smarty_tpl, $params); + return; + } + // try to load template function dynamically + if (Smarty_Internal_Function_Call_Handler::call($name, $_smarty_tpl, $function)) { + $function ($_smarty_tpl, $params); + return; + } + } + throw new SmartyException("Unable to find template function '{$name}'"); + } + +} \ No newline at end of file