diff --git a/docs/en/designers/language-basic-syntax.xml b/docs/en/designers/language-basic-syntax.xml
index 0cbd54e0..3e813810 100644
--- a/docs/en/designers/language-basic-syntax.xml
+++ b/docs/en/designers/language-basic-syntax.xml
@@ -26,6 +26,7 @@
Comments
+
{html_options values=$vals selected=$selected output=$output}
-</SELECT>
+
+]]>
+
@@ -99,6 +102,7 @@
function attribute syntax
+
{html_options values=$vals selected=$selected output=$output}
-</SELECT>
-
-
+
+]]>
+
+
+
Embedding Vars in Double Quotes
- Smarty will recognize assigned variables embedded in double quotes so long
- as the variables contain only numbers, letters, underscores and brackets
- []. With any other characters (period, object reference, etc.) the variable
- must be surrounded by backticks.
+ Smarty will recognize assigned variables embedded in double quotes so long
+ as the variables contain only numbers, letters, underscores and brackets
+ []. With any other characters (period, object reference, etc.) the variable
+ must be surrounded by backticks.
embedded quotes syntax
+
-
-
+{include file="subdir/$tpl_name.tpl"} <-- will replace $tpl_name with value
+{cycle values="one,two,`$smarty.config.myval`"} <-- must have backticks
+]]>
+
+
+
Math
- Math can be applied directly to variable values.
+ Math can be applied directly to variable values.
math examples
+bar-$bar[1]*$baz->foo->bar()-3*7}
{if ($foo+$bar.test%$baz*134232+10+$b+10)}
{$foo|truncate:"`$fooTruncCount/$barTruncFactor-1`"}
-{assign var="foo" value="`$foo+$bar`"}
-
-
+{assign var="foo" value="`$foo+$bar`"}
+]]>
+
+
+
Escaping Smarty Parsing
- It is sometimes desirable or even necessary to have Smarty ignore sections it
- would otherwise parse. A classic example is embedding Javascript or CSS code in
+ It is sometimes desirable or even necessary to have Smarty ignore sections it
+ would otherwise parse. A classic example is embedding Javascript or CSS code in
a template. The problem arises as those languages use the { and } characters
which are also the default delimiters for Smarty.
- The simplest thing is to avoid the situation altogether by separating your Javascript
- and CSS code into their own files and then using standard HTML methods to access them.
-
-
- Including literal content is possible using {literal} .. {/literal} blocks.
- Similar to HTML entity usage, you can use {ldelim} and {rdelim}
- to display the current delimiters.
+ The simplest thing is to avoid the situation altogether by separating your Javascript
+ and CSS code into their own files and then using standard HTML methods to access them.
- It is often convenient to simply change Smarty's $left_delimiter and
- $right_delimiter.
+ Including literal content is possible using {literal} .. {/literal} blocks.
+ Similar to HTML entity usage, you can use {ldelim} and {rdelim} to display the current delimiters.
+
+
+
+ It is often convenient to simply change Smarty's $left_delimiter and
+ $right_delimiter.
changing delimiters example
-
+
+left_delimiter = '<!--{';
-$smarty->right_delimiter = '}-->';
+$smarty->left_delimiter = '';
$smarty->assign('foo', 'bar');
$smarty->display('example.tpl');
+?>
+
--- example.tpl
-<script language="javascript">
-var foo = <!--{$foo}-->;
+
+]]>
+
+
+
+
\ No newline at end of file
+-->
diff --git a/docs/en/designers/language-variables.xml b/docs/en/designers/language-variables.xml
index 162ceb58..b37eb47a 100644
--- a/docs/en/designers/language-variables.xml
+++ b/docs/en/designers/language-variables.xml
@@ -3,8 +3,8 @@
Variables
- Smarty has several different types of variables. The type of the variable
- depends on what symbol it is prefixed with (or enclosed within).
+ Smarty has several different types of variables. The type of the variable
+ depends on what symbol it is prefixed with (or enclosed within).
@@ -13,128 +13,169 @@
etc. To print a variable, simply enclose it in the delimiters so that it
is the only thing contained between them. Examples:
+
+
+]]>
+ Variables assigned from PHP
- Variables that are assigned from PHP are referenced by preceding them with
- a dollar sign $. Variables assigned from within the
- template with the assign
- function are also displayed this way.
+ Variables that are assigned from PHP are referenced by preceding them with
+ a dollar sign $. Variables assigned from within the
+ template with the assign
+ function are also displayed this way.
assigned variables
-
+
+
Your last login was on {$lastLoginDate}.
-
-OUTPUT:
-
+]]>
+
+
+ This will output:
+
+
+
-
+
+Your last login was on January 11th, 2001.
+]]>
+
+
Associative arrays
- You can also reference associative array variables that are
- assigned from PHP by specifying the key after the '.' (period)
- symbol.
+ You can also reference associative array variables that are
+ assigned from PHP by specifying the key after the '.' (period)
+ symbol.
-
-accessing associative array variables
-
-index.php:
-
+
+ accessing associative array variables
+
+assign('Contacts',
array('fax' => '555-222-9876',
'email' => 'zaphod@slartibartfast.com',
'phone' => array('home' => '555-444-3333',
'cell' => '555-111-1234')));
-$smarty->display('index.tpl');
-
-index.tpl:
-
-{$Contacts.fax}<br>
-{$Contacts.email}<br>
+$smarty->display('index.tpl');
+?>
+]]>
+
+
+ where the content of index.tpl is:
+
+
+
+{$Contacts.email}
{* you can print arrays of arrays as well *}
-{$Contacts.phone.home}<br>
-{$Contacts.phone.cell}<br>
-
-OUTPUT:
-
-555-222-9876<br>
-zaphod@slartibartfast.com<br>
-555-444-3333<br>
-555-111-1234<br>
-
+{$Contacts.phone.home}
+{$Contacts.phone.cell}
+]]>
+
+
+ this will output:
+
+
+
+zaphod@slartibartfast.com
+555-444-3333
+555-111-1234
+]]>
+
+
-
+ Array indexes
- You can reference arrays by their index, much like native PHP
- syntax.
+ You can reference arrays by their index, much like native PHP
+ syntax.
-
-accessing arrays by index
-
-index.php:
+
+ accessing arrays by index
+
+assign('Contacts',
array('555-222-9876',
'zaphod@slartibartfast.com',
array('555-444-3333',
'555-111-1234')));
-$smarty->display('index.tpl');
+$smarty->display('index.tpl');
-index.tpl:
-
-{$Contacts[0]}<br>
-{$Contacts[1]}<br>
+?>
+]]>
+
+
+ where index.tpl is:
+
+
+
+{$Contacts[1]}
{* you can print arrays of arrays as well *}
-{$Contacts[2][0]}<br>
-{$Contacts[2][1]}<br>
+{$Contacts[2][0]}
+{$Contacts[2][1]}
+]]>
+
+
+ This will output:
+
+
+
+zaphod@slartibartfast.com
+555-444-3333
+555-111-1234
+]]>
+
+
+
+
+ Objects
+
+ Properties of objects assigned from PHP can be referenced
+ by specifying the property name after the '->' symbol.
+
+
+ accessing object properties
+
+
+email: {$person->email}
+]]>
+
+
+ this will output:
+
+
+
+email: zaphod@slartibartfast.com
+]]>
+
+
+
+
-OUTPUT:
-
-555-222-9876<br>
-zaphod@slartibartfast.com<br>
-555-444-3333<br>
-555-111-1234<br>
-
-
-
- Objects
-
- Properties of objects assigned from PHP can be referenced
- by specifying the property name after the '->' symbol.
-
-
-accessing object properties
-
-name: {$person->name}<br>
-email: {$person->email}<br>
-
-OUTPUT:
-
-name: Zaphod Beeblebrox<br>
-email: zaphod@slartibartfast.com<br>
-
-
-
-
-
+ Variables loaded from config files
Variables that are loaded from the config files are referenced by
@@ -144,92 +185,105 @@ email: zaphod@slartibartfast.com<br>
The second syntax is useful for embedding into quoted attribute
values.
-
-
-config variables
-
-foo.conf:
-
+
+ config variables
+
+ foo.conf:
+
+
+
+
+
+ index.tpl:
+
+
+
+{#pageTitle#}
+
+