- fix to make calling of template functions unambiguously by madatory usage of the {call} tag

This commit is contained in:
Uwe.Tews
2010-04-30 21:06:07 +00:00
parent 0920b383c6
commit ecf66837b5
3 changed files with 7 additions and 12 deletions

9
README
View File

@@ -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)}
<li>{$entry@key}</li>
{menu data=$entry level=$level+1}
{call name=menu data=$entry level=$level+1}
{else}
<li>{$entry}</li>
{/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:

View File

@@ -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 =====

View File

@@ -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) {