source: trunk/include/smarty/SMARTY_2_BC_NOTES.txt @ 23384

Last change on this file since 23384 was 23384, checked in by rvelices, 11 years ago

smarty 3 - first pass for tests

File size: 4.4 KB
Line 
1= Known incompatibilities with Smarty 2 =
2
3== Syntax ==
4
5Smarty 3 API has a new syntax. Much of the Smarty 2 syntax is supported
6by a wrapper but deprecated. See the README that comes with Smarty 3 for more
7information.
8
9The {$array|@mod} syntax has always been a bit confusing, where an "@" is required
10to apply a modifier to an array instead of the individual elements. Normally you
11always want the modifier to apply to the variable regardless of its type. In Smarty 3,
12{$array|mod} and {$array|@mod} behave identical. It is safe to drop the "@" and the
13modifier will still apply to the array. If you really want the modifier to apply to
14each array element, you must loop the array in-template, or use a custom modifier that
15supports array iteration. Most smarty functions already escape values where necessary
16such as {html_options}
17
18== PHP Version ==
19Smarty 3 is PHP 5 only. It will not work with PHP 4.
20
21== {php} Tag ==
22The {php} tag is disabled by default. The use of {php} tags is
23deprecated. It can be enabled with $smarty->allow_php_tag=true.
24
25But if you scatter PHP code which belongs together into several
26{php} tags it may not work any longer.
27
28== Delimiters and whitespace ==
29Delimiters surrounded by whitespace are no longer treated as Smarty tags.
30Therefore, { foo } will not compile as a tag, you must use {foo}. This change
31Makes Javascript/CSS easier to work with, eliminating the need for {literal}.
32This can be disabled by setting $smarty->auto_literal = false;
33
34== Unquoted Strings ==
35Smarty 2 was a bit more forgiving (and ambiguous) when it comes to unquoted strings
36in parameters. Smarty3 is more restrictive. You can still pass strings without quotes
37so long as they contain no special characters. (anything outside of A-Za-z0-9_)
38
39For example filename strings must be quoted
40<source lang="smarty">
41{include file='path/foo.tpl'}
42</source>
43
44== Extending the Smarty class ==
45Smarty 3 makes use of the __construct method for initialization. If you are extending
46the Smarty class, its constructor is not called implicitly if the your child class defines
47its own constructor. In order to run Smarty's constructor, a call to parent::__construct()
48within your child constructor is required.
49
50<source lang="php">
51class MySmarty extends Smarty {
52   function __construct() {
53       parent::__construct();
54   
55       // your initialization code goes here
56
57   }
58}
59</source>
60
61== Autoloader ==
62Smarty 3 does register its own autoloader with spl_autoload_register. If your code has
63an existing __autoload function then this function must be explicitly registered on
64the __autoload stack. See http://us3.php.net/manual/en/function.spl-autoload-register.php
65for further details.
66
67== Plugin Filenames ==
68Smarty 3 optionally supports the PHP spl_autoloader. The autoloader requires filenames
69to be lower case. Because of this, Smarty plugin file names must also be lowercase.
70In Smarty 2, mixed case file names did work.
71
72== Scope of Special Smarty Variables ==
73In Smarty 2 the special Smarty variables $smarty.section... and $smarty.foreach...
74had global scope. If you had loops with the same name in subtemplates you could accidentally
75overwrite values of parent template.
76
77In Smarty 3 these special Smarty variable have only local scope in the template which
78is defining the loop. If you need their value in a subtemplate you have to pass them
79as parameter.
80<source lang="smarty">
81{include file='path/foo.tpl' index=$smarty.section.foo.index}
82</source>
83
84== SMARTY_RESOURCE_CHAR_SET ==
85Smarty 3 sets the constant SMARTY_RESOURCE_CHAR_SET to utf-8 as default template charset.
86This is now used also on modifiers like escape as default charset. If your templates use
87other charsets make sure that you define the constant accordingly. Otherwise you may not
88get any output.
89
90== newline at {if} tags ==
91A \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.
92If one of the {if} tags is at the line end you will now get a newline in the HTML output.
93
94== trigger_error() ==
95The API function trigger_error() has been removed because it did just map to PHP trigger_error.
96However it's still included in the Smarty2 API wrapper.
97
98== Smarty constants ==
99The constants
100SMARTY_PHP_PASSTHRU
101SMARTY_PHP_QUOTE
102SMARTY_PHP_REMOVE
103SMARTY_PHP_ALLOW
104have been replaced with class constants
105Smarty::PHP_PASSTHRU
106Smarty::PHP_QUOTE
107Smarty::PHP_REMOVE
108Smarty::PHP_ALLOW
109
Note: See TracBrowser for help on using the repository browser.