diff --git a/README b/README index 37fe3183..c6b9906c 100644 --- a/README +++ b/README @@ -269,8 +269,9 @@ Just as you can use PHP functions as modifiers directly, you can now access PHP functions directly, provided they are permitted by security settings: {time()} -There is a new {function}...{/function} block tag. This enables reuse of code -sequences like a plugin function. It can call itself recursively. +There is a new {function}...{/function} block tag to implement a template function. +This enables reuse of code sequences like a plugin function. It can call itself recursively. +Template function must be called with the new {call name=foo...} tag. Example: @@ -280,7 +281,7 @@ Template file: {foreach $data as $entry} {if is_array($entry)}
  • {$entry@key}
  • - {menu data=$entry level=$level+1} + {call name=menu data=$entry level=$level+1} {else}
  • {$entry}
  • {/if} @@ -291,7 +292,7 @@ Template file: {$menu = ['item1','item2','item3' => ['item3-1','item3-2','item3-3' => ['item3-3-1','item3-3-2']],'item4']} -{menu data=$menu} +{call name=menu data=$menu} Generated output: diff --git a/change_log.txt b/change_log.txt index 32b3d217..1fc4d1ab 100644 --- a/change_log.txt +++ b/change_log.txt @@ -3,6 +3,7 @@ - work around of a substr_compare bug in older PHP5 versions - bugfix on template inheritance for tag names starting with "block" - bugfix on {function} tag with name attribute in doublequoted strings +- fix to make calling of template functions unambiguously by madatory usage of the {call} tag ===== RC1 ===== diff --git a/libs/sysplugins/smarty_internal_templatecompilerbase.php b/libs/sysplugins/smarty_internal_templatecompilerbase.php index 36054ef1..d11c2abc 100644 --- a/libs/sysplugins/smarty_internal_templatecompilerbase.php +++ b/libs/sysplugins/smarty_internal_templatecompilerbase.php @@ -110,14 +110,7 @@ class Smarty_Internal_TemplateCompilerBase { $this->has_code = true; $this->has_output = false; // compile the smarty tag (required compile classes to compile the tag are autoloaded) - if (($_output = $this->callTagCompiler($tag, $args)) === false) { - if (isset($this->smarty->template_functions[$tag])) { - // template defined by {template} tag - $args['name'] = "'" . $tag . "'"; - $_output = $this->callTagCompiler('call', $args); - } - } - if ($_output !== false) { + if (($_output = $this->callTagCompiler($tag, $args)) !== false) { if ($_output !== true) { // did we get compiled code if ($this->has_code) {