mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 10:24:26 +02:00
remove blanks on line endings
This commit is contained in:
@@ -7,7 +7,6 @@ Since 3.1.28 you can mix inheritance by extends resource with the {extends} tag.
|
|||||||
A template called by extends resource can extend a subtemplate or chain buy the {extends} tag.
|
A template called by extends resource can extend a subtemplate or chain buy the {extends} tag.
|
||||||
Since 3.1.31 this feature can be turned off by setting the new Smarty property Smarty::$extends_recursion to false.
|
Since 3.1.31 this feature can be turned off by setting the new Smarty property Smarty::$extends_recursion to false.
|
||||||
|
|
||||||
|
|
||||||
3.1.28
|
3.1.28
|
||||||
Starting with version 3.1.28 template inheritance is no longer a compile time process.
|
Starting with version 3.1.28 template inheritance is no longer a compile time process.
|
||||||
All {block} tag parent/child relations are resolved at run time.
|
All {block} tag parent/child relations are resolved at run time.
|
||||||
@@ -75,13 +74,11 @@ With this setting all {include} subtemplate will be merge into the compiled inhe
|
|||||||
could be rejected by exception.
|
could be rejected by exception.
|
||||||
|
|
||||||
|
|
||||||
If $smarty->inheritance_merge_compiled_includes = false; {include} subtemplate will not be merged.
|
If $smarty->inheritance_merge_compiled_includes = false; {include} subtemplate will not be merged.You must now manually merge all {include} subtemplate which do contain {block} tags. This is done by setting the "inline" option.
|
||||||
You must now manually merge all {include} subtemplate which do contain {block} tags. This is done by setting the "inline" option.
|
|
||||||
{include file='foo.bar' inline}
|
{include file='foo.bar' inline}
|
||||||
|
|
||||||
1. In case of a variable file name like {include file=$foo inline} you must use the variable in a compile_id $smarty->compile_id = $foo;
|
1. In case of a variable file name like {include file=$foo inline} you must use the variable in a compile_id $smarty->compile_id = $foo;
|
||||||
2. If you use individual compile_id in {include file='foo.tpl' compile_id=$bar inline} it must be used in the
|
2. If you use individual compile_id in {include file='foo.tpl' compile_id=$bar inline} it must be used in the global compile_id as well $smarty->compile_id = $bar;
|
||||||
global compile_id as well $smarty->compile_id = $bar;
|
|
||||||
3. If call templates with different template_dir configurations and a parent could same named child template from different folders
|
3. If call templates with different template_dir configurations and a parent could same named child template from different folders
|
||||||
you must make the folder name part of the compile_id.
|
you must make the folder name part of the compile_id.
|
||||||
|
|
||||||
|
@@ -15,7 +15,7 @@ Smarty 3.1.32
|
|||||||
New Methods
|
New Methods
|
||||||
$smarty->setLiterals(array $literals)
|
$smarty->setLiterals(array $literals)
|
||||||
$smarty->addLiterals(array $literals)
|
$smarty->addLiterals(array $literals)
|
||||||
to define lietrals containing Smarty delimiter. This can avoid the need for extreme usage
|
to define literals containing Smarty delimiter. This can avoid the need for extreme usage
|
||||||
of {literal} {/literal} tags.
|
of {literal} {/literal} tags.
|
||||||
A) Treat '{{' and '}}' as literal
|
A) Treat '{{' and '}}' as literal
|
||||||
If Smarty::$auto_literal is enabled
|
If Smarty::$auto_literal is enabled
|
||||||
@@ -28,7 +28,7 @@ Smarty 3.1.32
|
|||||||
NOTE: In the last example nested Smarty tags starting with '{{' or ending with '}}' will not
|
NOTE: In the last example nested Smarty tags starting with '{{' or ending with '}}' will not
|
||||||
work any longer, but this should be very very raw occouring restriction.
|
work any longer, but this should be very very raw occouring restriction.
|
||||||
B) Example 2
|
B) Example 2
|
||||||
Assume your delimiter are '<-' , '->' and '<--' , '-->' shall be lietrals
|
Assume your delimiter are '<-' , '->' and '<--' , '-->' shall be literals
|
||||||
$smarty->setLiteral(array('<--','-->'));
|
$smarty->setLiteral(array('<--','-->'));
|
||||||
|
|
||||||
|
|
||||||
@@ -87,8 +87,7 @@ Smarty 3.1.30
|
|||||||
{/foreach}
|
{/foreach}
|
||||||
|
|
||||||
The {foreach} loop is rendered while processing the compiled template, but $current is a nocache
|
The {foreach} loop is rendered while processing the compiled template, but $current is a nocache
|
||||||
variable. Normally the {if $current==$item.id} would fail as the $item variable is unknown in the
|
variable. Normally the {if $current==$item.id} would fail as the $item variable is unknown in the cached template. {make_nocache $item} does make the current $item value known in thee cached template.
|
||||||
cached template. {make_nocache $item} does make the current $item value known in thee cached template.
|
|
||||||
|
|
||||||
{make_nocache} is ignored when caching is disabled or the variable does exists as nocache variable.
|
{make_nocache} is ignored when caching is disabled or the variable does exists as nocache variable.
|
||||||
|
|
||||||
@@ -123,8 +122,7 @@ Smarty 3.1.30
|
|||||||
Supported scope are parent, tpl_root, smarty, global and root.
|
Supported scope are parent, tpl_root, smarty, global and root.
|
||||||
A scope used together with the {include} tag will cause that with some exceptions any variable
|
A scope used together with the {include} tag will cause that with some exceptions any variable
|
||||||
assignment within that sub-template will update/assign the variable in other scopes according
|
assignment within that sub-template will update/assign the variable in other scopes according
|
||||||
to the above rules. It does include also variables assigned by plugins, tags supporting the assign=foo
|
to the above rules. It does include also variables assigned by plugins, tags supporting the assign=foo attribute and direct assignments in {if} and {while} like {if $foo=$bar}.
|
||||||
attribute and direct assignments in {if} and {while} like {if $foo=$bar}.
|
|
||||||
Excluded are the key and value variables of {foreach}, {for} loop variables , variables passed by attributes
|
Excluded are the key and value variables of {foreach}, {for} loop variables , variables passed by attributes
|
||||||
in {include} and direct increments/decrements like {$foo++}, {$foo--}
|
in {include} and direct increments/decrements like {$foo++}, {$foo--}
|
||||||
|
|
||||||
@@ -174,8 +172,8 @@ Smarty 3.1.28
|
|||||||
as the corresponding Smarty methods to get the content of another template.
|
as the corresponding Smarty methods to get the content of another template.
|
||||||
Example:
|
Example:
|
||||||
$template->display(); Does display template of template object
|
$template->display(); Does display template of template object
|
||||||
$template->display('foo.tpl'); Does display template 'foo.bar'
|
$template->display('foo.tpl'); Does display template 'foo.bar'
|
||||||
|
|
||||||
File: resource
|
File: resource
|
||||||
==============
|
==============
|
||||||
Multiple template_dir entries can now be selected by a comma separated list of indices.
|
Multiple template_dir entries can now be selected by a comma separated list of indices.
|
||||||
|
64
README
64
README
@@ -176,7 +176,7 @@ backward compatible with Smarty 2, except for the following items:
|
|||||||
|
|
||||||
|
|
||||||
There are many things that are new to Smarty 3. Here are the notable items:
|
There are many things that are new to Smarty 3. Here are the notable items:
|
||||||
|
|
||||||
LEXER/PARSER
|
LEXER/PARSER
|
||||||
============
|
============
|
||||||
|
|
||||||
@@ -197,8 +197,8 @@ is still supported for BC.
|
|||||||
Examples:
|
Examples:
|
||||||
{$x+$y} will output the sum of x and y.
|
{$x+$y} will output the sum of x and y.
|
||||||
{$foo = strlen($bar)} function in assignment
|
{$foo = strlen($bar)} function in assignment
|
||||||
{assign var=foo value= $x+$y} in attributes
|
{assign var=foo value= $x+$y} in attributes
|
||||||
{$foo = myfunct( ($x+$y)*3 )} as function parameter
|
{$foo = myfunct( ($x+$y)*3 )} as function parameter
|
||||||
{$foo[$x+3]} as array index
|
{$foo[$x+3]} as array index
|
||||||
|
|
||||||
Smarty tags can be used as values within other tags.
|
Smarty tags can be used as values within other tags.
|
||||||
@@ -239,18 +239,18 @@ Examples:
|
|||||||
|
|
||||||
The original "dot" notation stays, and with improvements.
|
The original "dot" notation stays, and with improvements.
|
||||||
Examples:
|
Examples:
|
||||||
{$foo.a.b.c} => $foo['a']['b']['c']
|
{$foo.a.b.c} => $foo['a']['b']['c']
|
||||||
{$foo.a.$b.c} => $foo['a'][$b]['c'] with variable index
|
{$foo.a.$b.c} => $foo['a'][$b]['c'] with variable index
|
||||||
{$foo.a.{$b+4}.c} => $foo['a'][$b+4]['c'] with expression as index
|
{$foo.a.{$b+4}.c} => $foo['a'][$b+4]['c'] with expression as index
|
||||||
{$foo.a.{$b.c}} => $foo['a'][$b['c']] with nested index
|
{$foo.a.{$b.c}} => $foo['a'][$b['c']] with nested index
|
||||||
|
|
||||||
note that { and } are used to address ambiguties when nesting the dot syntax.
|
note that { and } are used to address ambiguties when nesting the dot syntax.
|
||||||
|
|
||||||
Variable names themselves can be variable and contain expressions.
|
Variable names themselves can be variable and contain expressions.
|
||||||
Examples:
|
Examples:
|
||||||
$foo normal variable
|
$foo normal variable
|
||||||
$foo_{$bar} variable name containing other variable
|
$foo_{$bar} variable name containing other variable
|
||||||
$foo_{$x+$y} variable name containing expressions
|
$foo_{$x+$y} variable name containing expressions
|
||||||
$foo_{$bar}_buh_{$blar} variable name with multiple segments
|
$foo_{$bar}_buh_{$blar} variable name with multiple segments
|
||||||
{$foo_{$x}} will output the variable $foo_1 if $x has a value of 1.
|
{$foo_{$x}} will output the variable $foo_1 if $x has a value of 1.
|
||||||
|
|
||||||
@@ -290,7 +290,7 @@ $var@last true on last iteration
|
|||||||
|
|
||||||
The Smarty 2 {foreach} tag syntax is still supported.
|
The Smarty 2 {foreach} tag syntax is still supported.
|
||||||
|
|
||||||
NOTE: {$bar[foo]} still indicates a variable inside of a {section} named foo.
|
NOTE: {$bar[foo]} still indicates a variable inside of a {section} named foo.
|
||||||
If you want to access an array element with index foo, you must use quotes
|
If you want to access an array element with index foo, you must use quotes
|
||||||
such as {$bar['foo']}, or use the dot syntax {$bar.foo}.
|
such as {$bar['foo']}, or use the dot syntax {$bar.foo}.
|
||||||
|
|
||||||
@@ -377,12 +377,12 @@ $smarty->display('string:This is my template, {$foo}!'); // php
|
|||||||
VARIABLE SCOPE / VARIABLE STORAGE
|
VARIABLE SCOPE / VARIABLE STORAGE
|
||||||
=================================
|
=================================
|
||||||
|
|
||||||
In Smarty 2, all assigned variables were stored within the Smarty object.
|
In Smarty 2, all assigned variables were stored within the Smarty object.
|
||||||
Therefore, all variables assigned in PHP were accessible by all subsequent
|
Therefore, all variables assigned in PHP were accessible by all subsequent
|
||||||
fetch and display template calls.
|
fetch and display template calls.
|
||||||
|
|
||||||
In Smarty 3, we have the choice to assign variables to the main Smarty object,
|
In Smarty 3, we have the choice to assign variables to the main Smarty object,
|
||||||
to user-created data objects, and to user-created template objects.
|
to user-created data objects, and to user-created template objects.
|
||||||
These objects can be chained. The object at the end of a chain can access all
|
These objects can be chained. The object at the end of a chain can access all
|
||||||
variables belonging to that template and all variables within the parent objects.
|
variables belonging to that template and all variables within the parent objects.
|
||||||
The Smarty object can only be the root of a chain, but a chain can be isolated
|
The Smarty object can only be the root of a chain, but a chain can be isolated
|
||||||
@@ -396,7 +396,7 @@ global variables.
|
|||||||
A Smarty data object can be created as follows:
|
A Smarty data object can be created as follows:
|
||||||
$data = $smarty->createData(); // create root data object
|
$data = $smarty->createData(); // create root data object
|
||||||
$data->assign('foo','bar'); // assign variables as usual
|
$data->assign('foo','bar'); // assign variables as usual
|
||||||
$data->config_load('my.conf'); // load config file
|
$data->config_load('my.conf'); // load config file
|
||||||
|
|
||||||
$data= $smarty->createData($smarty); // create data object having a parent link to
|
$data= $smarty->createData($smarty); // create data object having a parent link to
|
||||||
the Smarty object
|
the Smarty object
|
||||||
@@ -414,7 +414,7 @@ The first parameter can be a template name, a smarty object or a data object.
|
|||||||
Examples:
|
Examples:
|
||||||
$tpl = $smarty->createTemplate('mytpl.tpl'); // create template object not linked to any parent
|
$tpl = $smarty->createTemplate('mytpl.tpl'); // create template object not linked to any parent
|
||||||
$tpl->assign('foo','bar'); // directly assign variables
|
$tpl->assign('foo','bar'); // directly assign variables
|
||||||
$tpl->config_load('my.conf'); // load config file
|
$tpl->config_load('my.conf'); // load config file
|
||||||
|
|
||||||
$tpl = $smarty->createTemplate('mytpl.tpl',$smarty); // create template having a parent link to the Smarty object
|
$tpl = $smarty->createTemplate('mytpl.tpl',$smarty); // create template having a parent link to the Smarty object
|
||||||
$tpl = $smarty->createTemplate('mytpl.tpl',$data); // create template having a parent link to the $data object
|
$tpl = $smarty->createTemplate('mytpl.tpl',$data); // create template having a parent link to the $data object
|
||||||
@@ -424,31 +424,31 @@ If the $parent parameter is not specified in these method calls, the template ob
|
|||||||
is will link back to the Smarty object as it's parent.
|
is will link back to the Smarty object as it's parent.
|
||||||
|
|
||||||
If a template is called by an {include...} tag from another template, the
|
If a template is called by an {include...} tag from another template, the
|
||||||
subtemplate links back to the calling template as it's parent.
|
subtemplate links back to the calling template as it's parent.
|
||||||
|
|
||||||
All variables assigned locally or from a parent template are accessible. If the
|
All variables assigned locally or from a parent template are accessible. If the
|
||||||
template creates or modifies a variable by using the {assign var=foo...} or
|
template creates or modifies a variable by using the {assign var=foo...} or
|
||||||
{$foo=...} tags, these new values are only known locally (local scope). When the
|
{$foo=...} tags, these new values are only known locally (local scope). When the
|
||||||
template exits, none of the new variables or modifications can be seen in the
|
template exits, none of the new variables or modifications can be seen in the
|
||||||
parent template(s). This is same behavior as in Smarty 2.
|
parent template(s). This is same behavior as in Smarty 2.
|
||||||
|
|
||||||
With Smarty 3, we can assign variables with a scope attribute which allows the
|
With Smarty 3, we can assign variables with a scope attribute which allows the
|
||||||
availablility of these new variables or modifications globally (ie in the parent
|
availablility of these new variables or modifications globally (ie in the parent
|
||||||
templates.)
|
templates.)
|
||||||
|
|
||||||
Possible scopes are local, parent, root and global.
|
Possible scopes are local, parent, root and global.
|
||||||
Examples:
|
Examples:
|
||||||
{assign var=foo value='bar'} // no scope is specified, the default 'local'
|
{assign var=foo value='bar'} // no scope is specified, the default 'local'
|
||||||
{$foo='bar'} // same, local scope
|
{$foo='bar'} // same, local scope
|
||||||
{assign var=foo value='bar' scope='local'} // same, local scope
|
{assign var=foo value='bar' scope='local'} // same, local scope
|
||||||
|
|
||||||
{assign var=foo value='bar' scope='parent'} // Values will be available to the parent object
|
{assign var=foo value='bar' scope='parent'} // Values will be available to the parent object
|
||||||
{$foo='bar' scope='parent'} // (normally the calling template)
|
{$foo='bar' scope='parent'} // (normally the calling template)
|
||||||
|
|
||||||
{assign var=foo value='bar' scope='root'} // Values will be exported up to the root object, so they can
|
{assign var=foo value='bar' scope='root'} // Values will be exported up to the root object, so they can
|
||||||
{$foo='bar' scope='root'} // be seen from all templates using the same root.
|
{$foo='bar' scope='root'} // be seen from all templates using the same root.
|
||||||
|
|
||||||
{assign var=foo value='bar' scope='global'} // Values will be exported to global variable storage,
|
{assign var=foo value='bar' scope='global'} // Values will be exported to global variable storage,
|
||||||
{$foo='bar' scope='global'} // they are available to any and all templates.
|
{$foo='bar' scope='global'} // they are available to any and all templates.
|
||||||
|
|
||||||
|
|
||||||
@@ -460,8 +460,8 @@ included template.
|
|||||||
PLUGINS
|
PLUGINS
|
||||||
=======
|
=======
|
||||||
|
|
||||||
Smarty 3 plugins follow the same coding rules as in Smarty 2.
|
Smarty 3 plugins follow the same coding rules as in Smarty 2.
|
||||||
The main difference is that the template object is now passed in place of the smarty object.
|
The main difference is that the template object is now passed in place of the smarty object.
|
||||||
The smarty object can be still be accessed through $template->smarty.
|
The smarty object can be still be accessed through $template->smarty.
|
||||||
|
|
||||||
smarty_plugintype_name (array $params, Smarty_Internal_Template $template)
|
smarty_plugintype_name (array $params, Smarty_Internal_Template $template)
|
||||||
@@ -473,7 +473,7 @@ TEMPLATE INHERITANCE:
|
|||||||
=====================
|
=====================
|
||||||
|
|
||||||
With template inheritance you can define blocks, which are areas that can be
|
With template inheritance you can define blocks, which are areas that can be
|
||||||
overridden by child templates, so your templates could look like this:
|
overridden by child templates, so your templates could look like this:
|
||||||
|
|
||||||
parent.tpl:
|
parent.tpl:
|
||||||
<html>
|
<html>
|
||||||
@@ -491,14 +491,14 @@ parent.tpl:
|
|||||||
</html>
|
</html>
|
||||||
|
|
||||||
child.tpl:
|
child.tpl:
|
||||||
{extends file='parent.tpl'}
|
{extends file='parent.tpl'}
|
||||||
{block name='title'}
|
{block name='title'}
|
||||||
Child title
|
Child title
|
||||||
{/block}
|
{/block}
|
||||||
|
|
||||||
grandchild.tpl:
|
grandchild.tpl:
|
||||||
{extends file='child.tpl'}
|
{extends file='child.tpl'}
|
||||||
{block name='title'}Home - {$smarty.block.parent}{/block}
|
{block name='title'}Home - {$smarty.block.parent}{/block}
|
||||||
{block name='page-title'}My home{/block}
|
{block name='page-title'}My home{/block}
|
||||||
{block name='content'}
|
{block name='content'}
|
||||||
{foreach $images as $img}
|
{foreach $images as $img}
|
||||||
@@ -508,10 +508,10 @@ grandchild.tpl:
|
|||||||
|
|
||||||
We redefined all the blocks here, however in the title block we used {$smarty.block.parent},
|
We redefined all the blocks here, however in the title block we used {$smarty.block.parent},
|
||||||
which tells Smarty to insert the default content from the parent template in its place.
|
which tells Smarty to insert the default content from the parent template in its place.
|
||||||
The content block was overridden to display the image files, and page-title has also be
|
The content block was overridden to display the image files, and page-title has also be
|
||||||
overridden to display a completely different title.
|
overridden to display a completely different title.
|
||||||
|
|
||||||
If we render grandchild.tpl we will get this:
|
If we render grandchild.tpl we will get this:
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Home - Child title</title>
|
<title>Home - Child title</title>
|
||||||
@@ -529,8 +529,8 @@ If we render grandchild.tpl we will get this:
|
|||||||
NOTE: In the child templates everything outside the {extends} or {block} tag sections
|
NOTE: In the child templates everything outside the {extends} or {block} tag sections
|
||||||
is ignored.
|
is ignored.
|
||||||
|
|
||||||
The inheritance tree can be as big as you want (meaning you can extend a file that
|
The inheritance tree can be as big as you want (meaning you can extend a file that
|
||||||
extends another one that extends another one and so on..), but be aware that all files
|
extends another one that extends another one and so on..), but be aware that all files
|
||||||
have to be checked for modifications at runtime so the more inheritance the more overhead you add.
|
have to be checked for modifications at runtime so the more inheritance the more overhead you add.
|
||||||
|
|
||||||
Instead of defining the parent/child relationships with the {extends} tag in the child template you
|
Instead of defining the parent/child relationships with the {extends} tag in the child template you
|
||||||
@@ -538,7 +538,7 @@ can use the resource as follow:
|
|||||||
|
|
||||||
$smarty->display('extends:parent.tpl|child.tpl|grandchild.tpl');
|
$smarty->display('extends:parent.tpl|child.tpl|grandchild.tpl');
|
||||||
|
|
||||||
Child {block} tags may optionally have a append or prepend attribute. In this case the parent block content
|
Child {block} tags may optionally have a append or prepend attribute. In this case the parent block content
|
||||||
is appended or prepended to the child block content.
|
is appended or prepended to the child block content.
|
||||||
|
|
||||||
{block name='title' append} My title {/block}
|
{block name='title' append} My title {/block}
|
||||||
|
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
== Syntax ==
|
== Syntax ==
|
||||||
|
|
||||||
Smarty 3 API has a new syntax. Much of the Smarty 2 syntax is supported
|
Smarty 3 API has a new syntax. Much of the Smarty 2 syntax is supported
|
||||||
by a wrapper but deprecated. See the README that comes with Smarty 3 for more
|
by a wrapper but deprecated. See the README that comes with Smarty 3 for more
|
||||||
information.
|
information.
|
||||||
|
|
||||||
The {$array|@mod} syntax has always been a bit confusing, where an "@" is required
|
The {$array|@mod} syntax has always been a bit confusing, where an "@" is required
|
||||||
@@ -32,9 +32,9 @@ Makes Javascript/CSS easier to work with, eliminating the need for {literal}.
|
|||||||
This can be disabled by setting $smarty->auto_literal = false;
|
This can be disabled by setting $smarty->auto_literal = false;
|
||||||
|
|
||||||
== Unquoted Strings ==
|
== Unquoted Strings ==
|
||||||
Smarty 2 was a bit more forgiving (and ambiguous) when it comes to unquoted strings
|
Smarty 2 was a bit more forgiving (and ambiguous) when it comes to unquoted strings
|
||||||
in parameters. Smarty3 is more restrictive. You can still pass strings without quotes
|
in parameters. Smarty3 is more restrictive. You can still pass strings without quotes
|
||||||
so long as they contain no special characters. (anything outside of A-Za-z0-9_)
|
so long as they contain no special characters. (anything outside of A-Za-z0-9_)
|
||||||
|
|
||||||
For example filename strings must be quoted
|
For example filename strings must be quoted
|
||||||
<source lang="smarty">
|
<source lang="smarty">
|
||||||
@@ -42,16 +42,16 @@ For example filename strings must be quoted
|
|||||||
</source>
|
</source>
|
||||||
|
|
||||||
== Extending the Smarty class ==
|
== Extending the Smarty class ==
|
||||||
Smarty 3 makes use of the __construct method for initialization. If you are extending
|
Smarty 3 makes use of the __construct method for initialization. If you are extending
|
||||||
the Smarty class, its constructor is not called implicitly if the your child class defines
|
the Smarty class, its constructor is not called implicitly if the your child class defines
|
||||||
its own constructor. In order to run Smarty's constructor, a call to parent::__construct()
|
its own constructor. In order to run Smarty's constructor, a call to parent::__construct()
|
||||||
within your child constructor is required.
|
within your child constructor is required.
|
||||||
|
|
||||||
<source lang="php">
|
<source lang="php">
|
||||||
class MySmarty extends Smarty {
|
class MySmarty extends Smarty {
|
||||||
function __construct() {
|
function __construct() {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
// your initialization code goes here
|
// your initialization code goes here
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -59,36 +59,36 @@ class MySmarty extends Smarty {
|
|||||||
</source>
|
</source>
|
||||||
|
|
||||||
== Autoloader ==
|
== Autoloader ==
|
||||||
Smarty 3 does register its own autoloader with spl_autoload_register. If your code has
|
Smarty 3 does register its own autoloader with spl_autoload_register. If your code has
|
||||||
an existing __autoload function then this function must be explicitly registered on
|
an existing __autoload function then this function must be explicitly registered on
|
||||||
the __autoload stack. See http://us3.php.net/manual/en/function.spl-autoload-register.php
|
the __autoload stack. See http://us3.php.net/manual/en/function.spl-autoload-register.php
|
||||||
for further details.
|
for further details.
|
||||||
|
|
||||||
== Plugin Filenames ==
|
== Plugin Filenames ==
|
||||||
Smarty 3 optionally supports the PHP spl_autoloader. The autoloader requires filenames
|
Smarty 3 optionally supports the PHP spl_autoloader. The autoloader requires filenames
|
||||||
to be lower case. Because of this, Smarty plugin file names must also be lowercase.
|
to be lower case. Because of this, Smarty plugin file names must also be lowercase.
|
||||||
In Smarty 2, mixed case file names did work.
|
In Smarty 2, mixed case file names did work.
|
||||||
|
|
||||||
== Scope of Special Smarty Variables ==
|
== Scope of Special Smarty Variables ==
|
||||||
In Smarty 2 the special Smarty variables $smarty.section... and $smarty.foreach...
|
In Smarty 2 the special Smarty variables $smarty.section... and $smarty.foreach...
|
||||||
had global scope. If you had loops with the same name in subtemplates you could accidentally
|
had global scope. If you had loops with the same name in subtemplates you could accidentally
|
||||||
overwrite values of parent template.
|
overwrite values of parent template.
|
||||||
|
|
||||||
In Smarty 3 these special Smarty variable have only local scope in the template which
|
In Smarty 3 these special Smarty variable have only local scope in the template which
|
||||||
is defining the loop. If you need their value in a subtemplate you have to pass them
|
is defining the loop. If you need their value in a subtemplate you have to pass them
|
||||||
as parameter.
|
as parameter.
|
||||||
<source lang="smarty">
|
<source lang="smarty">
|
||||||
{include file='path/foo.tpl' index=$smarty.section.foo.index}
|
{include file='path/foo.tpl' index=$smarty.section.foo.index}
|
||||||
</source>
|
</source>
|
||||||
|
|
||||||
== SMARTY_RESOURCE_CHAR_SET ==
|
== SMARTY_RESOURCE_CHAR_SET ==
|
||||||
Smarty 3 sets the constant SMARTY_RESOURCE_CHAR_SET to utf-8 as default template charset.
|
Smarty 3 sets the constant SMARTY_RESOURCE_CHAR_SET to utf-8 as default template charset.
|
||||||
This is now used also on modifiers like escape as default charset. If your templates use
|
This is now used also on modifiers like escape as default charset. If your templates use
|
||||||
other charsets make sure that you define the constant accordingly. Otherwise you may not
|
other charsets make sure that you define the constant accordingly. Otherwise you may not
|
||||||
get any output.
|
get any output.
|
||||||
|
|
||||||
== newline at {if} tags ==
|
== newline at {if} tags ==
|
||||||
A \n was added to the compiled code of the {if},{else},{elseif},{/if} tags to get output of newlines as expected by the template source.
|
A \n was added to the compiled code of the {if},{else},{elseif},{/if} tags to get output of newlines as expected by the template source.
|
||||||
If one of the {if} tags is at the line end you will now get a newline in the HTML output.
|
If one of the {if} tags is at the line end you will now get a newline in the HTML output.
|
||||||
|
|
||||||
== trigger_error() ==
|
== trigger_error() ==
|
||||||
@@ -96,7 +96,7 @@ The API function trigger_error() has been removed because it did just map to PHP
|
|||||||
However it's still included in the Smarty2 API wrapper.
|
However it's still included in the Smarty2 API wrapper.
|
||||||
|
|
||||||
== Smarty constants ==
|
== Smarty constants ==
|
||||||
The constants
|
The constants
|
||||||
SMARTY_PHP_PASSTHRU
|
SMARTY_PHP_PASSTHRU
|
||||||
SMARTY_PHP_QUOTE
|
SMARTY_PHP_QUOTE
|
||||||
SMARTY_PHP_REMOVE
|
SMARTY_PHP_REMOVE
|
||||||
|
@@ -3,12 +3,12 @@ All Smarty2 specific API functions and deprecated functionality has been moved
|
|||||||
to the SmartyBC class.
|
to the SmartyBC class.
|
||||||
|
|
||||||
== {php} Tag ==
|
== {php} Tag ==
|
||||||
The {php} tag is no longer available in the standard Smarty calls.
|
The {php} tag is no longer available in the standard Smarty calls.
|
||||||
The use of {php} tags is deprecated and only available in the SmartyBC class.
|
The use of {php} tags is deprecated and only available in the SmartyBC class.
|
||||||
|
|
||||||
== {include_php} Tag ==
|
== {include_php} Tag ==
|
||||||
The {include_php} tag is no longer available in the standard Smarty calls.
|
The {include_php} tag is no longer available in the standard Smarty calls.
|
||||||
The use of {include_php} tags is deprecated and only available in the SmartyBC class.
|
The use of {include_php} tags is deprecated and only available in the SmartyBC class.
|
||||||
|
|
||||||
== php template resource ==
|
== php template resource ==
|
||||||
The support of the php template resource is removed.
|
The support of the php template resource is removed.
|
||||||
|
@@ -62,7 +62,7 @@ entity.
|
|||||||
|
|
||||||
default_template_handler_func
|
default_template_handler_func
|
||||||
|
|
||||||
The invocation of $smarty->$default_template_handler_func had to be
|
The invocation of $smarty->$default_template_handler_func had to be
|
||||||
altered. Instead of a Smarty_Internal_Template, the fifth argument is
|
altered. Instead of a Smarty_Internal_Template, the fifth argument is
|
||||||
now provided with the Smarty instance. New footprint:
|
now provided with the Smarty instance. New footprint:
|
||||||
|
|
||||||
@@ -71,14 +71,14 @@ now provided with the Smarty instance. New footprint:
|
|||||||
* Default Template Handler
|
* Default Template Handler
|
||||||
*
|
*
|
||||||
* called when Smarty's file: resource is unable to load a requested file
|
* called when Smarty's file: resource is unable to load a requested file
|
||||||
*
|
*
|
||||||
* @param string $type resource type (e.g. "file", "string", "eval", "resource")
|
* @param string $type resource type (e.g. "file", "string", "eval", "resource")
|
||||||
* @param string $name resource name (e.g. "foo/bar.tpl")
|
* @param string $name resource name (e.g. "foo/bar.tpl")
|
||||||
* @param string &$content template's content
|
* @param string &$content template's content
|
||||||
* @param integer &$modified template's modification time
|
* @param integer &$modified template's modification time
|
||||||
* @param Smarty $smarty Smarty instance
|
* @param Smarty $smarty Smarty instance
|
||||||
* @return string|boolean path to file or boolean true if $content and $modified
|
* @return string|boolean path to file or boolean true if $content and $modified
|
||||||
* have been filled, boolean false if no default template
|
* have been filled, boolean false if no default template
|
||||||
* could be loaded
|
* could be loaded
|
||||||
*/
|
*/
|
||||||
function default_template_handler_func($type, $name, &$content, &$modified, Smarty $smarty) {
|
function default_template_handler_func($type, $name, &$content, &$modified, Smarty $smarty) {
|
||||||
@@ -186,8 +186,8 @@ Note that old-fashioned registration of $cache_handler is not possible
|
|||||||
anymore. As the functionality had not been ported to Smarty 3.0.x
|
anymore. As the functionality had not been ported to Smarty 3.0.x
|
||||||
properly, it has been dropped from 3.1 completely.
|
properly, it has been dropped from 3.1 completely.
|
||||||
|
|
||||||
Locking facilities have been implemented to avoid concurrent cache
|
Locking facilities have been implemented to avoid concurrent cache
|
||||||
generation. Enable cache locking by setting
|
generation. Enable cache locking by setting
|
||||||
$smarty->cache_locking = true;
|
$smarty->cache_locking = true;
|
||||||
|
|
||||||
Relative Paths in Templates (File-Resource)
|
Relative Paths in Templates (File-Resource)
|
||||||
@@ -258,7 +258,7 @@ default_config_handler_func() has been introduced.
|
|||||||
|
|
||||||
default_plugin_handler_func()
|
default_plugin_handler_func()
|
||||||
|
|
||||||
An optional default_plugin_handler_func() can be defined which gets called
|
An optional default_plugin_handler_func() can be defined which gets called
|
||||||
by the compiler on tags which can't be resolved internally or by plugins.
|
by the compiler on tags which can't be resolved internally or by plugins.
|
||||||
The default_plugin_handler() can map tags to plugins on the fly.
|
The default_plugin_handler() can map tags to plugins on the fly.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user