mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-07 03:44:26 +02:00
- fix to make calling of template functions unambiguously by madatory usage of the {call} tag
This commit is contained in:
9
README
9
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:
|
PHP functions directly, provided they are permitted by security settings:
|
||||||
{time()}
|
{time()}
|
||||||
|
|
||||||
There is a new {function}...{/function} block tag. This enables reuse of code
|
There is a new {function}...{/function} block tag to implement a template function.
|
||||||
sequences like a plugin function. It can call itself recursively.
|
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:
|
Example:
|
||||||
|
|
||||||
@@ -280,7 +281,7 @@ Template file:
|
|||||||
{foreach $data as $entry}
|
{foreach $data as $entry}
|
||||||
{if is_array($entry)}
|
{if is_array($entry)}
|
||||||
<li>{$entry@key}</li>
|
<li>{$entry@key}</li>
|
||||||
{menu data=$entry level=$level+1}
|
{call name=menu data=$entry level=$level+1}
|
||||||
{else}
|
{else}
|
||||||
<li>{$entry}</li>
|
<li>{$entry}</li>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -291,7 +292,7 @@ Template file:
|
|||||||
{$menu = ['item1','item2','item3' => ['item3-1','item3-2','item3-3' =>
|
{$menu = ['item1','item2','item3' => ['item3-1','item3-2','item3-3' =>
|
||||||
['item3-3-1','item3-3-2']],'item4']}
|
['item3-3-1','item3-3-2']],'item4']}
|
||||||
|
|
||||||
{menu data=$menu}
|
{call name=menu data=$menu}
|
||||||
|
|
||||||
|
|
||||||
Generated output:
|
Generated output:
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
- work around of a substr_compare bug in older PHP5 versions
|
- work around of a substr_compare bug in older PHP5 versions
|
||||||
- bugfix on template inheritance for tag names starting with "block"
|
- bugfix on template inheritance for tag names starting with "block"
|
||||||
- bugfix on {function} tag with name attribute in doublequoted strings
|
- 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 =====
|
===== RC1 =====
|
||||||
|
|
||||||
|
@@ -110,14 +110,7 @@ class Smarty_Internal_TemplateCompilerBase {
|
|||||||
$this->has_code = true;
|
$this->has_code = true;
|
||||||
$this->has_output = false;
|
$this->has_output = false;
|
||||||
// compile the smarty tag (required compile classes to compile the tag are autoloaded)
|
// compile the smarty tag (required compile classes to compile the tag are autoloaded)
|
||||||
if (($_output = $this->callTagCompiler($tag, $args)) === false) {
|
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 !== true) {
|
if ($_output !== true) {
|
||||||
// did we get compiled code
|
// did we get compiled code
|
||||||
if ($this->has_code) {
|
if ($this->has_code) {
|
||||||
|
Reference in New Issue
Block a user