mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-03 18:04:26 +02:00
*** empty log message ***
This commit is contained in:
@@ -7,9 +7,11 @@ $smarty = new Smarty;
|
|||||||
$smarty->assign("Name","Fred");
|
$smarty->assign("Name","Fred");
|
||||||
$smarty->assign("FirstName",array("John","Mary","James","Henry"));
|
$smarty->assign("FirstName",array("John","Mary","James","Henry"));
|
||||||
$smarty->assign("LastName",array("Doe","Smith","Johnson","Case"));
|
$smarty->assign("LastName",array("Doe","Smith","Johnson","Case"));
|
||||||
$smarty->assign("Class",array("A","B","C","D"));
|
$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->spew("./templates/index.tpl");
|
$smarty->spew("./templates/index.tpl");
|
||||||
|
|
||||||
|
print "\ndone\n";
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@@ -1,63 +1,11 @@
|
|||||||
{include header.tpl}
|
{include header.tpl}
|
||||||
|
|
||||||
{* A simple variable test *}
|
{* A simple variable test *}
|
||||||
hello, my name is {$Name}.<br>
|
hello, my name is {$Name}.<br>
|
||||||
{if $Name eq "Joe"}
|
{if $Name eq "Joe"}
|
||||||
I am Joe.<br>
|
I am {ldelim}Joe{rdelim}.<br>
|
||||||
{else}
|
{else}
|
||||||
I am not Joe.<br>
|
I am not Joe.<br>
|
||||||
{/if}
|
{/if}
|
||||||
<p>
|
|
||||||
Lets loop through some information:<br>
|
|
||||||
{section name="outside" $FirstName}
|
|
||||||
current name is {$outside.LastName}, {$outside.FirstName}<br>
|
|
||||||
{section name=inside $Class}
|
|
||||||
current class is: {$inside.Class}<br>
|
|
||||||
{/section}
|
|
||||||
{if $outside.rownum.even}
|
|
||||||
row is even<br>
|
|
||||||
{else}
|
|
||||||
row is odd<br>
|
|
||||||
{/if}
|
|
||||||
{if $outside.rownum.mod.2}
|
|
||||||
row is evenly divisible by 2<br>
|
|
||||||
{else}
|
|
||||||
row is not evenly divisible by 2<br>
|
|
||||||
{/if}
|
|
||||||
{if $outside.rownum.even.2}
|
|
||||||
row is even, grouped by 2<br>
|
|
||||||
{else}
|
|
||||||
row is odd, grouped by 2<br>
|
|
||||||
{/if}
|
|
||||||
<p>
|
|
||||||
{/section}
|
|
||||||
|
|
||||||
{section name=blah $loopvar2}
|
|
||||||
test default: {htmlesc $blah.loopvar2}<br>
|
|
||||||
a free standing section.<br>
|
|
||||||
{/section}
|
|
||||||
|
|
||||||
By default, php code is escaped:<br>
|
|
||||||
<?php print "hello"; ?>
|
|
||||||
<p>
|
|
||||||
{* the config function at work *}
|
|
||||||
<p>
|
|
||||||
|
|
||||||
{configload "config/index.conf"}
|
|
||||||
config var title: {configprint "title"}<br>
|
|
||||||
config var Name: {configprint "Name"}<br>
|
|
||||||
{configset "Name", $test}
|
|
||||||
test is {htmlesc $test}<br>
|
|
||||||
{configclear}
|
|
||||||
<p>
|
|
||||||
The following text is {htmlesc "<HTML><ESCAPED>"}.<br>
|
|
||||||
{* This is a template comment *}
|
|
||||||
<p>
|
|
||||||
{strip}
|
|
||||||
All data within the<br>
|
|
||||||
{ldelim}strip{rdelim} tags is stripped<br>
|
|
||||||
of unneeded tabs, spaces and carriage returns<br>
|
|
||||||
at the beginning and end of lines<br>
|
|
||||||
in the html source (view this source)<br>
|
|
||||||
{/strip}
|
|
||||||
|
|
||||||
{include footer.tpl}
|
{include footer.tpl}
|
||||||
|
@@ -7,9 +7,11 @@ $smarty = new Smarty;
|
|||||||
$smarty->assign("Name","Fred");
|
$smarty->assign("Name","Fred");
|
||||||
$smarty->assign("FirstName",array("John","Mary","James","Henry"));
|
$smarty->assign("FirstName",array("John","Mary","James","Henry"));
|
||||||
$smarty->assign("LastName",array("Doe","Smith","Johnson","Case"));
|
$smarty->assign("LastName",array("Doe","Smith","Johnson","Case"));
|
||||||
$smarty->assign("Class",array("A","B","C","D"));
|
$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->spew("./templates/index.tpl");
|
$smarty->spew("./templates/index.tpl");
|
||||||
|
|
||||||
|
print "\ndone\n";
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@@ -1,63 +1,11 @@
|
|||||||
{include header.tpl}
|
{include header.tpl}
|
||||||
|
|
||||||
{* A simple variable test *}
|
{* A simple variable test *}
|
||||||
hello, my name is {$Name}.<br>
|
hello, my name is {$Name}.<br>
|
||||||
{if $Name eq "Joe"}
|
{if $Name eq "Joe"}
|
||||||
I am Joe.<br>
|
I am {ldelim}Joe{rdelim}.<br>
|
||||||
{else}
|
{else}
|
||||||
I am not Joe.<br>
|
I am not Joe.<br>
|
||||||
{/if}
|
{/if}
|
||||||
<p>
|
|
||||||
Lets loop through some information:<br>
|
|
||||||
{section name="outside" $FirstName}
|
|
||||||
current name is {$outside.LastName}, {$outside.FirstName}<br>
|
|
||||||
{section name=inside $Class}
|
|
||||||
current class is: {$inside.Class}<br>
|
|
||||||
{/section}
|
|
||||||
{if $outside.rownum.even}
|
|
||||||
row is even<br>
|
|
||||||
{else}
|
|
||||||
row is odd<br>
|
|
||||||
{/if}
|
|
||||||
{if $outside.rownum.mod.2}
|
|
||||||
row is evenly divisible by 2<br>
|
|
||||||
{else}
|
|
||||||
row is not evenly divisible by 2<br>
|
|
||||||
{/if}
|
|
||||||
{if $outside.rownum.even.2}
|
|
||||||
row is even, grouped by 2<br>
|
|
||||||
{else}
|
|
||||||
row is odd, grouped by 2<br>
|
|
||||||
{/if}
|
|
||||||
<p>
|
|
||||||
{/section}
|
|
||||||
|
|
||||||
{section name=blah $loopvar2}
|
|
||||||
test default: {htmlesc $blah.loopvar2}<br>
|
|
||||||
a free standing section.<br>
|
|
||||||
{/section}
|
|
||||||
|
|
||||||
By default, php code is escaped:<br>
|
|
||||||
<?php print "hello"; ?>
|
|
||||||
<p>
|
|
||||||
{* the config function at work *}
|
|
||||||
<p>
|
|
||||||
|
|
||||||
{configload "config/index.conf"}
|
|
||||||
config var title: {configprint "title"}<br>
|
|
||||||
config var Name: {configprint "Name"}<br>
|
|
||||||
{configset "Name", $test}
|
|
||||||
test is {htmlesc $test}<br>
|
|
||||||
{configclear}
|
|
||||||
<p>
|
|
||||||
The following text is {htmlesc "<HTML><ESCAPED>"}.<br>
|
|
||||||
{* This is a template comment *}
|
|
||||||
<p>
|
|
||||||
{strip}
|
|
||||||
All data within the<br>
|
|
||||||
{ldelim}strip{rdelim} tags is stripped<br>
|
|
||||||
of unneeded tabs, spaces and carriage returns<br>
|
|
||||||
at the beginning and end of lines<br>
|
|
||||||
in the html source (view this source)<br>
|
|
||||||
{/strip}
|
|
||||||
|
|
||||||
{include footer.tpl}
|
{include footer.tpl}
|
||||||
|
Reference in New Issue
Block a user