diff --git a/INHERITANCE_RELEASE_NOTES.txt b/INHERITANCE_RELEASE_NOTES.txt index d89060f0..2be8645f 100644 --- a/INHERITANCE_RELEASE_NOTES.txt +++ b/INHERITANCE_RELEASE_NOTES.txt @@ -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. Since 3.1.31 this feature can be turned off by setting the new Smarty property Smarty::$extends_recursion to false. - 3.1.28 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. @@ -75,13 +74,11 @@ With this setting all {include} subtemplate will be merge into the compiled inhe could be rejected by exception. -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. +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. {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; -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; +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; 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. diff --git a/NEW_FEATURES.txt b/NEW_FEATURES.txt index 83945638..66a9f604 100644 --- a/NEW_FEATURES.txt +++ b/NEW_FEATURES.txt @@ -15,7 +15,7 @@ Smarty 3.1.32 New Methods $smarty->setLiterals(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. A) Treat '{{' and '}}' as literal 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 work any longer, but this should be very very raw occouring restriction. B) Example 2 - Assume your delimiter are '<-' , '->' and '<--' , '-->' shall be lietrals + Assume your delimiter are '<-' , '->' and '<--' , '-->' shall be literals $smarty->setLiteral(array('<--','-->')); @@ -87,8 +87,7 @@ Smarty 3.1.30 {/foreach} 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 - cached template. {make_nocache $item} does make the current $item value known in thee cached template. + 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. {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. 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 - 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}. + 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}. 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--} @@ -174,8 +172,8 @@ Smarty 3.1.28 as the corresponding Smarty methods to get the content of another template. Example: $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 ============== Multiple template_dir entries can now be selected by a comma separated list of indices. diff --git a/README b/README index 6a86afff..9a71519b 100644 --- a/README +++ b/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: - + LEXER/PARSER ============ @@ -197,8 +197,8 @@ is still supported for BC. Examples: {$x+$y} will output the sum of x and y. {$foo = strlen($bar)} function in assignment -{assign var=foo value= $x+$y} in attributes -{$foo = myfunct( ($x+$y)*3 )} as function parameter +{assign var=foo value= $x+$y} in attributes +{$foo = myfunct( ($x+$y)*3 )} as function parameter {$foo[$x+3]} as array index Smarty tags can be used as values within other tags. @@ -239,18 +239,18 @@ Examples: The original "dot" notation stays, and with improvements. 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+4}.c} => $foo['a'][$b+4]['c'] with expression as 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. Examples: $foo normal variable -$foo_{$bar} variable name containing other variable -$foo_{$x+$y} variable name containing expressions +$foo_{$bar} variable name containing other variable +$foo_{$x+$y} variable name containing expressions $foo_{$bar}_buh_{$blar} variable name with multiple segments {$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. -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 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 ================================= -In Smarty 2, all assigned variables were stored within the Smarty object. -Therefore, all variables assigned in PHP were accessible by all subsequent +In Smarty 2, all assigned variables were stored within the Smarty object. +Therefore, all variables assigned in PHP were accessible by all subsequent fetch and display template calls. -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. +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. 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. 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: $data = $smarty->createData(); // create root data object $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 the Smarty object @@ -414,7 +414,7 @@ The first parameter can be a template name, a smarty object or a data object. Examples: $tpl = $smarty->createTemplate('mytpl.tpl'); // create template object not linked to any parent $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',$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. 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 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 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 availablility of these new variables or modifications globally (ie in the parent templates.) -Possible scopes are local, parent, root and global. +Possible scopes are local, parent, root and global. Examples: {assign var=foo value='bar'} // no scope is specified, the default 'local' {$foo='bar'} // 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) -{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. -{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. @@ -460,8 +460,8 @@ included template. PLUGINS ======= -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. +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 smarty object can be still be accessed through $template->smarty. 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 -overridden by child templates, so your templates could look like this: +overridden by child templates, so your templates could look like this: parent.tpl: @@ -491,14 +491,14 @@ parent.tpl: child.tpl: -{extends file='parent.tpl'} +{extends file='parent.tpl'} {block name='title'} Child title {/block} grandchild.tpl: -{extends file='child.tpl'} -{block name='title'}Home - {$smarty.block.parent}{/block} +{extends file='child.tpl'} +{block name='title'}Home - {$smarty.block.parent}{/block} {block name='page-title'}My home{/block} {block name='content'} {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}, 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 -overridden to display a completely different title. +The content block was overridden to display the image files, and page-title has also be +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: