diff --git a/Smarty_Compiler.class.php b/Smarty_Compiler.class.php index 5a7884c5..6fcfdbe2 100644 --- a/Smarty_Compiler.class.php +++ b/Smarty_Compiler.class.php @@ -55,6 +55,7 @@ class Smarty_Compiler extends Smarty { var $_si_qstr_regexp = null; var $_qstr_regexp = null; var $_func_regexp = null; + var $_dvar__gets_regexp = null; var $_dvar_regexp = null; var $_cvar_regexp = null; var $_svar_regexp = null; @@ -86,14 +87,15 @@ class Smarty_Compiler extends Smarty { $this->_qstr_regexp = '(?:' . $this->_db_qstr_regexp . '|' . $this->_si_qstr_regexp . ')'; // matches $ vars (not objects): - // $foo - // $foo.bar - // $foo.bar.foobar - // $foo[0] - // $foo[$bar] - // $foo[5][blah] - // $foo[5].bar[$foobar][4] - $this->_dvar_regexp = '\$\w+(?:\[\$?[\w\.]+\])*(?:\.\$?\w+(?:\[\$?[\w\.]+\])*)*'; + // foo + // foo.bar + // foo.bar.foobar + // foo[0] + // foo[$bar] + // foo[5][blah] + // foo[5].bar[$foobar][4] + $this->_dvar_guts_regexp = '\w+(?:\[\$?[\w\.]+\])*(?:\.\$?\w+(?:\[\$?[\w\.]+\])*)*'; + $this->_dvar_regexp = '\$' . $this->_dvar_guts_regexp; // matches config vars: // #foo# @@ -130,13 +132,15 @@ class Smarty_Compiler extends Smarty { // matches valid object call (no objects allowed in parameters): // $foo->bar + // $foo->bar[0] + // $foo->bar[$x].foobar // $foo->bar() // $foo->bar("text") // $foo->bar($foo, $bar, "text") // $foo->bar($foo|bar, "foo"|bar) // $foo->bar->foo() // $foo->bar->foo->bar() - $this->_obj_start_regexp = '(?:' . $this->_dvar_regexp . '(?:\->\w+)+)'; + $this->_obj_start_regexp = '(?:' . $this->_dvar_regexp . '(?:\->' . $this->_dvar_guts_regexp . ')+)'; $this->_obj_call_regexp = '(?:' . $this->_obj_start_regexp . '(?:\((?:\w+|' . $this->_var_regexp . '(?>' . $this->_mod_regexp . '*)(?:\s*,\s*(?:(?:\w+|' . $this->_var_regexp . '(?>' . $this->_mod_regexp . '*))))*)?\))?)'; diff --git a/configs/test.conf b/configs/test.conf index 73ff448e..5eac748e 100644 --- a/configs/test.conf +++ b/configs/test.conf @@ -1,5 +1,5 @@ -foo = foo_var +title = Welcome to Smarty! +cutoff_size = 40 -[foo] - -foo = section_foo_var +[setup] +bold = true diff --git a/demo/configs/test.conf b/demo/configs/test.conf index 73ff448e..5eac748e 100644 --- a/demo/configs/test.conf +++ b/demo/configs/test.conf @@ -1,5 +1,5 @@ -foo = foo_var +title = Welcome to Smarty! +cutoff_size = 40 -[foo] - -foo = section_foo_var +[setup] +bold = true diff --git a/demo/index.php b/demo/index.php index 1af61a8d..ebfe5750 100644 --- a/demo/index.php +++ b/demo/index.php @@ -1,76 +1,24 @@ force_compile = true; -//$smarty->left_delimiter = ''; -//$smarty->plugins_dir = array('plugins','./my_plugins'); -$smarty->plugins_dir = './plugins'; -//$smarty->use_sub_dirs = false; -//$smarty->caching = true; -//$smarty->cache_modified_check = true; -//$smarty->compile_check = false; -//$smarty->security = true; -//$smarty->security_settings['ALLOW_CONSTANTS'] = true; -//$smarty->trusted_dir=array("./trusted"); -//$smarty->secure_dir=array("./templates"); -//$smarty->default_template_handler_func = "make_tpl"; -//$smarty->debugging=true; +$smarty->compile_check = true; +$smarty->debugging = true; -define('_MY_CONST','myconst'); +$smarty->assign("Name","Fred Irving Johnathan Bradley Peppergill"); +$smarty->assign("FirstName",array("John","Mary","James","Henry")); +$smarty->assign("LastName",array("Doe","Smith","Johnson","Case")); +$smarty->assign("Class",array(array("A","B","C","D"), array("E", "F", "G", "H"), + array("I", "J", "K", "L"), array("M", "N", "O", "P"))); -$smarty->assign('foo','bar'); -$smarty->assign('bfoo',true); -$smarty->assign('bar','one'); -$smarty->assign('afoo',array('one' => 'foo', 'two' => 'bar')); +$smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"), + array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234"))); -class ofoo { - var $blah = 'myblah'; - function foo($var=null,$var2=null,$var3=null) { - return '[' . $var . '][' . $var2 . '][' . $var3 . ']'; - } -} - -$ofoo = new ofoo; - -$smarty->assign('ofoo',$ofoo); - -class nfoo { - var $ofoo = null; - function nfoo() { - $this->ofoo = new ofoo; - } -} - - -$nfoo = new nfoo; - -$smarty->assign('nfoo',$nfoo); - - -function _smarty_ffoo($params, &$smarty) { - foreach($params as $var) { - $return .= '[' . $var . ']'; - } - return $return; -} - -$smarty->register_function('ffoo','_smarty_ffoo'); - -$smarty->assign('sfoo',array('one','two','three')); - -function smarty_block_reverse($params, $content, &$smarty) { - if($content) { - return strrev($content); - } -} - -$smarty->register_block('reverse', 'smarty_block_reverse'); +$smarty->assign("option_values", array("NY","NE","KS","IA","OK","TX")); +$smarty->assign("option_output", array("New York","Nebraska","Kansas","Iowa","Oklahoma","Texas")); +$smarty->assign("option_selected", "NE"); $smarty->display('index.tpl'); diff --git a/demo/templates/index.tpl b/demo/templates/index.tpl index c46cd737..c4d5eeeb 100644 --- a/demo/templates/index.tpl +++ b/demo/templates/index.tpl @@ -1,189 +1,83 @@ -{* Smarty *} -BEGIN SMARTY SMOKE TEST +{config_load file=test.conf section="setup"} +{include file="header.tpl" title=foo} + +
+
+{* bold and title are read from the config file *}
+{if #bold#}{/if}
+{* capitalize the first letters of each word of the title *}
+Title: {#title#|capitalize}
+{if #bold#}{/if}
+
+The current date and time is {$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}
+
+Tooltip example: Move your mouse over the Help link to see an example of a tooltip using Smarty's popup function.
+
+The value of global assigned variable $SCRIPT_NAME is {$SCRIPT_NAME}
+
+Example of accessing server environment variable SERVER_NAME: {$smarty.server.SERVER_NAME}
+
+The value of {ldelim}$Name{rdelim} is {$Name}
+
+variable modifier example of {ldelim}$Name|upper{rdelim}
+
+{$Name|upper}
 
 
-plain variable $foo
--------------------
-
-$foo                                      {$foo}
-$foo|upper                                {$foo|upper}
-$foo|upper|spacify                        {$foo|upper|spacify}
-$foo|spacify:"^^"                         {$foo|spacify:"^^"}
-$foo|@count                               {$foo|@count}
-$foo|default:"no"                         {$foo|default:"no"}
-$foo|truncate:6:"...":true                {$foo|truncate:6:"...":true}
-
-associative variable $afoo
---------------------------
-
-$afoo.one                                 {$afoo.one}
-$afoo.two                                 {$afoo.two}
-$afoo.one|upper                           {$afoo.one|upper}
-$afoo.one|upper|spacify                   {$afoo.one|upper|spacify}
-$afoo.one|spacify:"^^"                    {$afoo.one|spacify:"^^"}
-$afoo.one|@count                          {$afoo.one|@count}
-$afoo.one|default:"no"                    {$afoo.one|default:"no"}
-$afoo.one|truncate:6:"...":true           {$afoo.one|truncate:6:"...":true}
-$afoo.$bar                                {$afoo.$bar}
-
-{config_load file="test.conf"}
-
-config variable #foo#
----------------------
-
-#foo#                                      {#foo#}
-#foo#|upper                                {#foo#|upper}
-#foo#|upper|spacify                        {#foo#|upper|spacify}
-#foo#|spacify:"^^"                         {#foo#|spacify:"^^"}
-#foo#|@count                               {#foo#|@count}
-#foo#|default:"no"                         {#foo#|default:"no"}
-#foo#|truncate:6:"...":true                {#foo#|truncate:6:"...":true}
-
-{config_load file="test.conf" section="foo"}
-
-config variable #foo# from section foo
---------------------------------------
-
-#foo#                                      {#foo#}
-#foo#|upper                                {#foo#|upper}
-#foo#|upper|spacify                        {#foo#|upper|spacify}
-#foo#|spacify:"^^"                         {#foo#|spacify:"^^"}
-#foo#|@count                               {#foo#|@count}
-#foo#|default:"no"                         {#foo#|default:"no"}
-#foo#|truncate:6:"...":true                {#foo#|truncate:6:"...":true}
-
-object $ofoo
-------------
-
-$ofoo->blah                               {$ofoo->blah}
-$ofoo->foo('bar')                         {$ofoo->foo('bar')}
-$ofoo->foo("bar")                         {$ofoo->foo("bar")}
-$ofoo->foo("$foo bar")                    {$ofoo->foo("$foo bar")}
-$ofoo->foo("one","two")                   {$ofoo->foo("one","two")}
-$ofoo->foo("one","two","three")           {$ofoo->foo("one","two","three")}
-$ofoo->foo("one $foo","two","three")      {$ofoo->foo("one $foo","two","three")}
-$ofoo->foo("one $foo","two $foo","three") {$ofoo->foo("one $foo","two $foo","three")}
-$ofoo->foo("one","two","three")           {$ofoo->foo("one","two","three","four")}
-$ofoo->foo('one $foo','two $foo','three') {$ofoo->foo('one $foo','two $foo','three')}
-$ofoo->foo('one')|upper                   {$ofoo->foo('one')|upper}
-
-
-nested object nfoo
-------------------
-
-
-$nfoo->ofoo->blah                               {$nfoo->ofoo->blah}
-$nfoo->ofoo->foo('bar')                         {$nfoo->ofoo->foo('bar')}
-$nfoo->ofoo->foo("bar")                         {$nfoo->ofoo->foo("bar")}
-$nfoo->ofoo->foo("$foo bar")                    {$nfoo->ofoo->foo("$foo bar")}
-$nfoo->ofoo->foo("one","two")                   {$nfoo->ofoo->foo("one","two")}
-$nfoo->ofoo->foo("one","two","three")           {$nfoo->ofoo->foo("one","two","three")}
-$nfoo->ofoo->foo("one $foo","two","three")      {$nfoo->ofoo->foo("one $foo","two","three")}
-$nfoo->ofoo->foo("one $foo","two $foo","three") {$nfoo->ofoo->foo("one $foo","two $foo","three")}
-$nfoo->ofoo->foo("one","two","three")           {$nfoo->ofoo->foo("one","two","three","four")}
-$nfoo->ofoo->foo('one $foo','two $foo','three') {$nfoo->ofoo->foo('one $foo','two $foo','three')}
-$nfoo->ofoo->foo('one')|upper                   {$nfoo->ofoo->foo('one')|upper}
-
-
-function ffoo
--------------
-
-ffoo var="foo"                            {ffoo var="foo"}
-ffoo var="foo" var2="blah"                {ffoo var="foo" var2="blah"}
-ffoo var=$foo                             {ffoo var=$foo}
-ffoo var=truey                            {ffoo var=truey}
-ffoo var=$foo|upper                       {ffoo var=$foo|upper}
-ffoo var="foo"|upper                      {ffoo var="foo"|upper}
-ffoo var=$ofoo->foo("$foo bar")           {ffoo var=$ofoo->foo("$foo bar")}
-ffoo|upper var=$foo                       {ffoo|upper var=$foo}
- 
-
-
-section loop over sfoo
-----------------------
-
-{section name=sec loop=$sfoo}
-$sfoo[sec]                                {$sfoo[sec]}
-$sfoo[sec.index]                          {$sfoo[sec.index]}
-$sfoo[sec.index_next]                     {$sfoo[sec.index_next]}
-$sfoo[sec.index_prev]                     {$sfoo[sec.index_prev]}
-$sfoo[sec.iteration]                      {$sfoo[sec.iteration]}
-$sfoo[sec.first]                          {$sfoo[sec.first]}
-$sfoo[sec.last]                           {$sfoo[sec.last]}
-$sfoo[sec.rownum]                         {$sfoo[sec.rownum]}
-$sfoo[sec.loop]                           {$sfoo[sec.loop]}
-$sfoo[sec.total]                          {$sfoo[sec.total]}
-$sfoo[sec.show]                           {$sfoo[sec.show]}
-$sfoo[sec]|upper                          {$sfoo[sec]|upper}
-$sfoo[sec]|upper|spacify                  {$sfoo[sec]|upper|spacify}
-$sfoo[sec]|spacify:"^^"                   {$sfoo[sec]|spacify:"^^"}
-$sfoo[sec]|@count                         {$sfoo[sec]|@count}
-$sfoo[sec]|default:"no"                   {$sfoo[sec]|default:"no"}
-$sfoo[sec]|truncate:6:"...":true          {$sfoo[sec]|truncate:6:"...":true}
-
-$smarty.section.sec.index                 {$smarty.section.sec.index}
+An example of a section loop:
 
+{section name=outer loop=$FirstName}
+{if %outer.index% is odd by 2}
+	{%outer.rownum%} . {$FirstName[outer]} {$LastName[outer]}
+{else}
+	{%outer.rownum%} * {$FirstName[outer]} {$LastName[outer]}
+{/if}
+{sectionelse}
+	none
 {/section}
 
-if statement parse test
------------------------
+An example of section looped key values:
 
-if $foo                                   {if $foo}{/if}(end)
-if $foo eq "bar"                          {if $foo eq "bar"}foo is bar{/if}(end)
-if is_array($foo)                         {if is_array($foo)}foo is array{else}foo is not array{/if}(end)
-if $foo gt 4                              {if $foo gt 4}$foo is gt 4{/if}(end)
-if ($foo gt 4)                            {if ($foo gt 4)}$foo is gt 4{/if}(end)
-if ( $foo gt 4 )                          {if ( $foo gt 4 )}$foo is gt 4{/if}(end)
-if $foo and not $bar                      {if $foo and not $bar}foo and not bar{/if}(end)
-if !$bfoo                                 {if !$bfoo}not bfoo{else}bfoo{/if}(end)
-if 4 is div by 4                          {if 4 is div by 4}div by 4{else}not div by 4{/if}(end)
-if 3 is div by 4                          {if 3 is div by 4}div by 4{else}not div by 4{/if}(end)
-if 3 is div by 4 or ( 3 eq 3 )            {if 3 is div by 4 or ( 3 eq 3 )}blah{/if}(end)
-if (3 is div by 4) or ( 3<="bah"|upper )  {if (3 is div by 4) or ( 3<="bah"|upper )}woohoo{/if}(end)
-if in_array("my $bar", $afoo)             {if in_array("my $bar", $afoo)}is in{else}is not in{/if}(end)
-if $ofoo->foo()                           {if $ofoo->foo()}is in{else}is not in{/if}(end)
-if in_array($ofoo->foo("two"), $afoo)     {if in_array($ofoo->foo("two"), $afoo)}is in{else}is not in{/if}(end)
-
-$smarty variable access
------------------------
-
-$smarty.now                               {$smarty.now}
-$smarty.const._MY_CONST                   {$smarty.const._MY_CONST}
-
-block function
---------------
-
-{reverse}
-	This is my block of text.
-{/reverse|upper}
-
-misc syntax, try to break
--------------------------
-
-$foo|spacify:"|"                          {$foo|spacify:"|"}
-$foo|spacify:"|"|upper                    {$foo|spacify:"|"|upper}
-$foo|spacify:"$foo"|upper|default:"|"     {$foo|spacify:"$foo"|upper|default:"|"}
-
-{section name=sec loop=$sfoo}
-$ofoo->foo($sfoo[sec],$sfoo[sec]|spacify:"^^",$sfoo[sec]|truncate:6:"...":true) {$ofoo->foo($sfoo[sec],$sfoo[sec]|spacify:"^^",$sfoo[sec]|truncate:6:"...":true)} 
-$nfoo->ofoo->foo($sfoo[sec],$sfoo[sec]|spacify:"^^",$sfoo[sec]|truncate:6:"...":true) {$nfoo->ofoo->foo($sfoo[sec],$sfoo[sec]|spacify:"^^",$sfoo[sec]|truncate:6:"...":true)} 
+{section name=sec1 loop=$contacts}
+	phone: {$contacts[sec1].phone}
+ fax: {$contacts[sec1].fax}
+ cell: {$contacts[sec1].cell}
{/section} +

-ffoo|spacify:"|"|upper var="lalala" {ffoo|spacify:"|"|upper var="lalala"} -ffoo|spacify:" my spaces "|upper var="lalala" {ffoo|spacify:" my spaces "|upper var="lalala"} -ffoo|spacify:"!@#$%^&*()_+=-\|]["|upper var="lalala" {ffoo|spacify:"!@#$%^&*()_+=-\|]["|upper var="lalala"} +testing strip tags +{strip} + + + + +
+ + This is a test + +
+{/strip} -{config_load file=test.conf section=foo} +

-if !$nfoo->ofoo->foo("blah blah") {if !$nfoo->ofoo->foo("blah blah")}not blah{else}blah{/if}(end) +This is an example of the html_select_date function: -"static"|upper {"static"|upper} +
+{html_select_date start_year=1998 end_year=2010} +
-{foreach item="fofoo" from=$afoo} +This is an example of the html_select_time function: -DEBUG FOREACH: {$fofoo} +
+{html_select_time use_24_hours=false} +
-{/foreach} +This is an example of the html_options function: -END SMARTY SMOKE TEST +
+ +
+{include file="footer.tpl"} diff --git a/index.php b/index.php index 1af61a8d..ebfe5750 100644 --- a/index.php +++ b/index.php @@ -1,76 +1,24 @@ force_compile = true; -//$smarty->left_delimiter = ''; -//$smarty->plugins_dir = array('plugins','./my_plugins'); -$smarty->plugins_dir = './plugins'; -//$smarty->use_sub_dirs = false; -//$smarty->caching = true; -//$smarty->cache_modified_check = true; -//$smarty->compile_check = false; -//$smarty->security = true; -//$smarty->security_settings['ALLOW_CONSTANTS'] = true; -//$smarty->trusted_dir=array("./trusted"); -//$smarty->secure_dir=array("./templates"); -//$smarty->default_template_handler_func = "make_tpl"; -//$smarty->debugging=true; +$smarty->compile_check = true; +$smarty->debugging = true; -define('_MY_CONST','myconst'); +$smarty->assign("Name","Fred Irving Johnathan Bradley Peppergill"); +$smarty->assign("FirstName",array("John","Mary","James","Henry")); +$smarty->assign("LastName",array("Doe","Smith","Johnson","Case")); +$smarty->assign("Class",array(array("A","B","C","D"), array("E", "F", "G", "H"), + array("I", "J", "K", "L"), array("M", "N", "O", "P"))); -$smarty->assign('foo','bar'); -$smarty->assign('bfoo',true); -$smarty->assign('bar','one'); -$smarty->assign('afoo',array('one' => 'foo', 'two' => 'bar')); +$smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"), + array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234"))); -class ofoo { - var $blah = 'myblah'; - function foo($var=null,$var2=null,$var3=null) { - return '[' . $var . '][' . $var2 . '][' . $var3 . ']'; - } -} - -$ofoo = new ofoo; - -$smarty->assign('ofoo',$ofoo); - -class nfoo { - var $ofoo = null; - function nfoo() { - $this->ofoo = new ofoo; - } -} - - -$nfoo = new nfoo; - -$smarty->assign('nfoo',$nfoo); - - -function _smarty_ffoo($params, &$smarty) { - foreach($params as $var) { - $return .= '[' . $var . ']'; - } - return $return; -} - -$smarty->register_function('ffoo','_smarty_ffoo'); - -$smarty->assign('sfoo',array('one','two','three')); - -function smarty_block_reverse($params, $content, &$smarty) { - if($content) { - return strrev($content); - } -} - -$smarty->register_block('reverse', 'smarty_block_reverse'); +$smarty->assign("option_values", array("NY","NE","KS","IA","OK","TX")); +$smarty->assign("option_output", array("New York","Nebraska","Kansas","Iowa","Oklahoma","Texas")); +$smarty->assign("option_selected", "NE"); $smarty->display('index.tpl'); diff --git a/libs/Smarty_Compiler.class.php b/libs/Smarty_Compiler.class.php index 5a7884c5..6fcfdbe2 100644 --- a/libs/Smarty_Compiler.class.php +++ b/libs/Smarty_Compiler.class.php @@ -55,6 +55,7 @@ class Smarty_Compiler extends Smarty { var $_si_qstr_regexp = null; var $_qstr_regexp = null; var $_func_regexp = null; + var $_dvar__gets_regexp = null; var $_dvar_regexp = null; var $_cvar_regexp = null; var $_svar_regexp = null; @@ -86,14 +87,15 @@ class Smarty_Compiler extends Smarty { $this->_qstr_regexp = '(?:' . $this->_db_qstr_regexp . '|' . $this->_si_qstr_regexp . ')'; // matches $ vars (not objects): - // $foo - // $foo.bar - // $foo.bar.foobar - // $foo[0] - // $foo[$bar] - // $foo[5][blah] - // $foo[5].bar[$foobar][4] - $this->_dvar_regexp = '\$\w+(?:\[\$?[\w\.]+\])*(?:\.\$?\w+(?:\[\$?[\w\.]+\])*)*'; + // foo + // foo.bar + // foo.bar.foobar + // foo[0] + // foo[$bar] + // foo[5][blah] + // foo[5].bar[$foobar][4] + $this->_dvar_guts_regexp = '\w+(?:\[\$?[\w\.]+\])*(?:\.\$?\w+(?:\[\$?[\w\.]+\])*)*'; + $this->_dvar_regexp = '\$' . $this->_dvar_guts_regexp; // matches config vars: // #foo# @@ -130,13 +132,15 @@ class Smarty_Compiler extends Smarty { // matches valid object call (no objects allowed in parameters): // $foo->bar + // $foo->bar[0] + // $foo->bar[$x].foobar // $foo->bar() // $foo->bar("text") // $foo->bar($foo, $bar, "text") // $foo->bar($foo|bar, "foo"|bar) // $foo->bar->foo() // $foo->bar->foo->bar() - $this->_obj_start_regexp = '(?:' . $this->_dvar_regexp . '(?:\->\w+)+)'; + $this->_obj_start_regexp = '(?:' . $this->_dvar_regexp . '(?:\->' . $this->_dvar_guts_regexp . ')+)'; $this->_obj_call_regexp = '(?:' . $this->_obj_start_regexp . '(?:\((?:\w+|' . $this->_var_regexp . '(?>' . $this->_mod_regexp . '*)(?:\s*,\s*(?:(?:\w+|' . $this->_var_regexp . '(?>' . $this->_mod_regexp . '*))))*)?\))?)'; diff --git a/templates/index.tpl b/templates/index.tpl index c46cd737..c4d5eeeb 100644 --- a/templates/index.tpl +++ b/templates/index.tpl @@ -1,189 +1,83 @@ -{* Smarty *} -BEGIN SMARTY SMOKE TEST +{config_load file=test.conf section="setup"} +{include file="header.tpl" title=foo} + +
+
+{* bold and title are read from the config file *}
+{if #bold#}{/if}
+{* capitalize the first letters of each word of the title *}
+Title: {#title#|capitalize}
+{if #bold#}{/if}
+
+The current date and time is {$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}
+
+Tooltip example: Move your mouse over the Help link to see an example of a tooltip using Smarty's popup function.
+
+The value of global assigned variable $SCRIPT_NAME is {$SCRIPT_NAME}
+
+Example of accessing server environment variable SERVER_NAME: {$smarty.server.SERVER_NAME}
+
+The value of {ldelim}$Name{rdelim} is {$Name}
+
+variable modifier example of {ldelim}$Name|upper{rdelim}
+
+{$Name|upper}
 
 
-plain variable $foo
--------------------
-
-$foo                                      {$foo}
-$foo|upper                                {$foo|upper}
-$foo|upper|spacify                        {$foo|upper|spacify}
-$foo|spacify:"^^"                         {$foo|spacify:"^^"}
-$foo|@count                               {$foo|@count}
-$foo|default:"no"                         {$foo|default:"no"}
-$foo|truncate:6:"...":true                {$foo|truncate:6:"...":true}
-
-associative variable $afoo
---------------------------
-
-$afoo.one                                 {$afoo.one}
-$afoo.two                                 {$afoo.two}
-$afoo.one|upper                           {$afoo.one|upper}
-$afoo.one|upper|spacify                   {$afoo.one|upper|spacify}
-$afoo.one|spacify:"^^"                    {$afoo.one|spacify:"^^"}
-$afoo.one|@count                          {$afoo.one|@count}
-$afoo.one|default:"no"                    {$afoo.one|default:"no"}
-$afoo.one|truncate:6:"...":true           {$afoo.one|truncate:6:"...":true}
-$afoo.$bar                                {$afoo.$bar}
-
-{config_load file="test.conf"}
-
-config variable #foo#
----------------------
-
-#foo#                                      {#foo#}
-#foo#|upper                                {#foo#|upper}
-#foo#|upper|spacify                        {#foo#|upper|spacify}
-#foo#|spacify:"^^"                         {#foo#|spacify:"^^"}
-#foo#|@count                               {#foo#|@count}
-#foo#|default:"no"                         {#foo#|default:"no"}
-#foo#|truncate:6:"...":true                {#foo#|truncate:6:"...":true}
-
-{config_load file="test.conf" section="foo"}
-
-config variable #foo# from section foo
---------------------------------------
-
-#foo#                                      {#foo#}
-#foo#|upper                                {#foo#|upper}
-#foo#|upper|spacify                        {#foo#|upper|spacify}
-#foo#|spacify:"^^"                         {#foo#|spacify:"^^"}
-#foo#|@count                               {#foo#|@count}
-#foo#|default:"no"                         {#foo#|default:"no"}
-#foo#|truncate:6:"...":true                {#foo#|truncate:6:"...":true}
-
-object $ofoo
-------------
-
-$ofoo->blah                               {$ofoo->blah}
-$ofoo->foo('bar')                         {$ofoo->foo('bar')}
-$ofoo->foo("bar")                         {$ofoo->foo("bar")}
-$ofoo->foo("$foo bar")                    {$ofoo->foo("$foo bar")}
-$ofoo->foo("one","two")                   {$ofoo->foo("one","two")}
-$ofoo->foo("one","two","three")           {$ofoo->foo("one","two","three")}
-$ofoo->foo("one $foo","two","three")      {$ofoo->foo("one $foo","two","three")}
-$ofoo->foo("one $foo","two $foo","three") {$ofoo->foo("one $foo","two $foo","three")}
-$ofoo->foo("one","two","three")           {$ofoo->foo("one","two","three","four")}
-$ofoo->foo('one $foo','two $foo','three') {$ofoo->foo('one $foo','two $foo','three')}
-$ofoo->foo('one')|upper                   {$ofoo->foo('one')|upper}
-
-
-nested object nfoo
-------------------
-
-
-$nfoo->ofoo->blah                               {$nfoo->ofoo->blah}
-$nfoo->ofoo->foo('bar')                         {$nfoo->ofoo->foo('bar')}
-$nfoo->ofoo->foo("bar")                         {$nfoo->ofoo->foo("bar")}
-$nfoo->ofoo->foo("$foo bar")                    {$nfoo->ofoo->foo("$foo bar")}
-$nfoo->ofoo->foo("one","two")                   {$nfoo->ofoo->foo("one","two")}
-$nfoo->ofoo->foo("one","two","three")           {$nfoo->ofoo->foo("one","two","three")}
-$nfoo->ofoo->foo("one $foo","two","three")      {$nfoo->ofoo->foo("one $foo","two","three")}
-$nfoo->ofoo->foo("one $foo","two $foo","three") {$nfoo->ofoo->foo("one $foo","two $foo","three")}
-$nfoo->ofoo->foo("one","two","three")           {$nfoo->ofoo->foo("one","two","three","four")}
-$nfoo->ofoo->foo('one $foo','two $foo','three') {$nfoo->ofoo->foo('one $foo','two $foo','three')}
-$nfoo->ofoo->foo('one')|upper                   {$nfoo->ofoo->foo('one')|upper}
-
-
-function ffoo
--------------
-
-ffoo var="foo"                            {ffoo var="foo"}
-ffoo var="foo" var2="blah"                {ffoo var="foo" var2="blah"}
-ffoo var=$foo                             {ffoo var=$foo}
-ffoo var=truey                            {ffoo var=truey}
-ffoo var=$foo|upper                       {ffoo var=$foo|upper}
-ffoo var="foo"|upper                      {ffoo var="foo"|upper}
-ffoo var=$ofoo->foo("$foo bar")           {ffoo var=$ofoo->foo("$foo bar")}
-ffoo|upper var=$foo                       {ffoo|upper var=$foo}
- 
-
-
-section loop over sfoo
-----------------------
-
-{section name=sec loop=$sfoo}
-$sfoo[sec]                                {$sfoo[sec]}
-$sfoo[sec.index]                          {$sfoo[sec.index]}
-$sfoo[sec.index_next]                     {$sfoo[sec.index_next]}
-$sfoo[sec.index_prev]                     {$sfoo[sec.index_prev]}
-$sfoo[sec.iteration]                      {$sfoo[sec.iteration]}
-$sfoo[sec.first]                          {$sfoo[sec.first]}
-$sfoo[sec.last]                           {$sfoo[sec.last]}
-$sfoo[sec.rownum]                         {$sfoo[sec.rownum]}
-$sfoo[sec.loop]                           {$sfoo[sec.loop]}
-$sfoo[sec.total]                          {$sfoo[sec.total]}
-$sfoo[sec.show]                           {$sfoo[sec.show]}
-$sfoo[sec]|upper                          {$sfoo[sec]|upper}
-$sfoo[sec]|upper|spacify                  {$sfoo[sec]|upper|spacify}
-$sfoo[sec]|spacify:"^^"                   {$sfoo[sec]|spacify:"^^"}
-$sfoo[sec]|@count                         {$sfoo[sec]|@count}
-$sfoo[sec]|default:"no"                   {$sfoo[sec]|default:"no"}
-$sfoo[sec]|truncate:6:"...":true          {$sfoo[sec]|truncate:6:"...":true}
-
-$smarty.section.sec.index                 {$smarty.section.sec.index}
+An example of a section loop:
 
+{section name=outer loop=$FirstName}
+{if %outer.index% is odd by 2}
+	{%outer.rownum%} . {$FirstName[outer]} {$LastName[outer]}
+{else}
+	{%outer.rownum%} * {$FirstName[outer]} {$LastName[outer]}
+{/if}
+{sectionelse}
+	none
 {/section}
 
-if statement parse test
------------------------
+An example of section looped key values:
 
-if $foo                                   {if $foo}{/if}(end)
-if $foo eq "bar"                          {if $foo eq "bar"}foo is bar{/if}(end)
-if is_array($foo)                         {if is_array($foo)}foo is array{else}foo is not array{/if}(end)
-if $foo gt 4                              {if $foo gt 4}$foo is gt 4{/if}(end)
-if ($foo gt 4)                            {if ($foo gt 4)}$foo is gt 4{/if}(end)
-if ( $foo gt 4 )                          {if ( $foo gt 4 )}$foo is gt 4{/if}(end)
-if $foo and not $bar                      {if $foo and not $bar}foo and not bar{/if}(end)
-if !$bfoo                                 {if !$bfoo}not bfoo{else}bfoo{/if}(end)
-if 4 is div by 4                          {if 4 is div by 4}div by 4{else}not div by 4{/if}(end)
-if 3 is div by 4                          {if 3 is div by 4}div by 4{else}not div by 4{/if}(end)
-if 3 is div by 4 or ( 3 eq 3 )            {if 3 is div by 4 or ( 3 eq 3 )}blah{/if}(end)
-if (3 is div by 4) or ( 3<="bah"|upper )  {if (3 is div by 4) or ( 3<="bah"|upper )}woohoo{/if}(end)
-if in_array("my $bar", $afoo)             {if in_array("my $bar", $afoo)}is in{else}is not in{/if}(end)
-if $ofoo->foo()                           {if $ofoo->foo()}is in{else}is not in{/if}(end)
-if in_array($ofoo->foo("two"), $afoo)     {if in_array($ofoo->foo("two"), $afoo)}is in{else}is not in{/if}(end)
-
-$smarty variable access
------------------------
-
-$smarty.now                               {$smarty.now}
-$smarty.const._MY_CONST                   {$smarty.const._MY_CONST}
-
-block function
---------------
-
-{reverse}
-	This is my block of text.
-{/reverse|upper}
-
-misc syntax, try to break
--------------------------
-
-$foo|spacify:"|"                          {$foo|spacify:"|"}
-$foo|spacify:"|"|upper                    {$foo|spacify:"|"|upper}
-$foo|spacify:"$foo"|upper|default:"|"     {$foo|spacify:"$foo"|upper|default:"|"}
-
-{section name=sec loop=$sfoo}
-$ofoo->foo($sfoo[sec],$sfoo[sec]|spacify:"^^",$sfoo[sec]|truncate:6:"...":true) {$ofoo->foo($sfoo[sec],$sfoo[sec]|spacify:"^^",$sfoo[sec]|truncate:6:"...":true)} 
-$nfoo->ofoo->foo($sfoo[sec],$sfoo[sec]|spacify:"^^",$sfoo[sec]|truncate:6:"...":true) {$nfoo->ofoo->foo($sfoo[sec],$sfoo[sec]|spacify:"^^",$sfoo[sec]|truncate:6:"...":true)} 
+{section name=sec1 loop=$contacts}
+	phone: {$contacts[sec1].phone}
+ fax: {$contacts[sec1].fax}
+ cell: {$contacts[sec1].cell}
{/section} +

-ffoo|spacify:"|"|upper var="lalala" {ffoo|spacify:"|"|upper var="lalala"} -ffoo|spacify:" my spaces "|upper var="lalala" {ffoo|spacify:" my spaces "|upper var="lalala"} -ffoo|spacify:"!@#$%^&*()_+=-\|]["|upper var="lalala" {ffoo|spacify:"!@#$%^&*()_+=-\|]["|upper var="lalala"} +testing strip tags +{strip} + + + + +
+ + This is a test + +
+{/strip} -{config_load file=test.conf section=foo} +

-if !$nfoo->ofoo->foo("blah blah") {if !$nfoo->ofoo->foo("blah blah")}not blah{else}blah{/if}(end) +This is an example of the html_select_date function: -"static"|upper {"static"|upper} +
+{html_select_date start_year=1998 end_year=2010} +
-{foreach item="fofoo" from=$afoo} +This is an example of the html_select_time function: -DEBUG FOREACH: {$fofoo} +
+{html_select_time use_24_hours=false} +
-{/foreach} +This is an example of the html_options function: -END SMARTY SMOKE TEST +
+ +
+{include file="footer.tpl"}