diff --git a/QUICKSTART b/QUICKSTART index a91e91d8..807352eb 100644 --- a/QUICKSTART +++ b/QUICKSTART @@ -63,7 +63,7 @@ $smarty->display("./templates/index.tpl"); Hello - Hello, {$Name}! + Hello, {$Name}! @@ -118,9 +118,9 @@ $smarty->display("./templates/index.tpl"); Hello - Hello, {$Name}!
- {$FirstName}, {$LastName}
- {$Address}, {$Zipcode} + Hello, {$Name}!
+ {$FirstName}, {$LastName}
+ {$Address}, {$Zipcode} @@ -143,10 +143,17 @@ require("Smarty.class.php"); $smarty = new Smarty; $smarty->assign("Name","Ned"); $smarty->assign(array( +<<<<<<< QUICKSTART + "FirstName" => "Fred", + "LastName" => "Flanders", + "Address" => "Springfield" + )); +======= "FirstName" => "Ned", "LastName" => "Flanders", "Address" => "Springfield" )); +>>>>>>> 1.2 $zipcode = "55555"; $smarty->assign("Zipcode",$zipcode); $smarty->display("./templates/index.tpl"); @@ -155,9 +162,9 @@ $smarty->display("./templates/index.tpl"); --------- templates/index.tpl -------- {include file="header.tpl" title="Home Page"} - Hello, {$Name}!
- {$FirstName}, {$LastName}
- {$Address}, {$Zipcode} + Hello, {$Name}!
+ {$FirstName}, {$LastName}
+ {$Address}, {$Zipcode} {include file="footer.tpl"} --------- templates/header.tpl -------- @@ -187,6 +194,18 @@ Example: --------- templates/index.tpl -------- {include file="header.tpl" title="Home Page"} +<<<<<<< QUICKSTART + {if $Name eq ""} + Hello, Noname!
+ {elseif $Name eq "Fred"} + Hello, Frederick!
+ {else} + Hello, {$Name}
+ {/if} + + {$FirstName}, {$LastName}
+ {$Address}, {$Zipcode} +======= {if $Name eq ""} Hello, Noname!
{elseif $Name eq "Ned"} @@ -197,6 +216,7 @@ Example: {$FirstName}, {$LastName}
{$Address}, {$Zipcode} +>>>>>>> 1.2 {include file="footer.tpl"} @@ -219,13 +239,13 @@ $smarty->display("./templates/index.tpl"); --------- templates/index.tpl -------- {include file="header.tpl" title="Home Page"} - {section name=people loop=$FirstName} - {%people.rownum%} {$people/FirstName} {$people/LastName}
- {sectionelse} - There are no values to loop through. - {/section} -

- There were {%people.loop%} names in this list. + {section name=people loop=$FirstName} + {%people.rownum%} {$people/FirstName} {$people/LastName}
+ {sectionelse} + There are no values to loop through. + {/section} +

+ There were {%people.loop%} names in this list. {include file="footer.tpl"} @@ -246,35 +266,35 @@ $smarty = new Smarty; $smarty->assign("FirstName",array("Ned","Bart","Montgomery")); $smarty->assign("LastName",array("Flanders","Simpson","Burns")); $smarty->assign("ContactNames",array( - array("email","home","cell"), - array("email","home"), - array("email","home","fax") - )); + array("email","home","cell"), + array("email","home"), + array("email","home","fax") + )); $smarty->assign("ContactVals",array( - array("fred@simpsons.com","555-666-7777","555-444-3333"), - array("bart@simpsons.com","555-111-2222"), - array("monty@simpsons.com","555-888-9999","555-234-5678"), - )); + array("fred@simpsons.com","555-666-7777","555-444-3333"), + array("bart@simpsons.com","555-111-2222"), + array("monty@simpsons.com","555-888-9999","555-234-5678"), + )); $smarty->display("./templates/index.tpl"); ?> --------- templates/index.tpl -------- {include file="header.tpl" title="Home Page"} - {section name=people loop=$FirstName} - {%people.rownum%} {$people/FirstName} {$people/LastName}
- {section name=contacts loop=$people/ContactNames} - {* for fun, lets bold every other row *} - {if %contacts.rownum% is even}{/if} - {$people/contacts/ContactNames}: {$people/contacts/ContactVals}
- {if %contacts.rownum% is even}
{/if} - {/section} -
- {sectionelse} - There are no values to loop through. - {/section} -

- There were {%people.loop%} names in this list. + {section name=people loop=$FirstName} + {%people.rownum%} {$people/FirstName} {$people/LastName}
+ {section name=contacts loop=$people/ContactNames} + {* for fun, lets bold every other row *} + {if %contacts.rownum% is even}{/if} + {$people/contacts/ContactNames}: {$people/contacts/ContactVals}
+ {if %contacts.rownum% is even}
{/if} + {/section} +
+ {sectionelse} + There are no values to loop through. + {/section} +

+ There were {%people.loop%} names in this list. {include file="footer.tpl"} diff --git a/Smarty.addons.php b/Smarty.addons.php index 216d3d94..fe5c278b 100644 --- a/Smarty.addons.php +++ b/Smarty.addons.php @@ -4,7 +4,8 @@ * Project: Smarty: the PHP compiled template engine * File: Smarty.addons.php * Author: Monte Ohrt - * Andrei Zmievski + * Andrei Zmievski + * Version: 1.0 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/Smarty.class.php b/Smarty.class.php index 1b21e404..3e1610c7 100644 --- a/Smarty.class.php +++ b/Smarty.class.php @@ -7,6 +7,7 @@ * * Andrei Zmievski * parsing engine rewrite and a lot more + * Version: 1.0 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/demo/index.php b/demo/index.php index 83565f8a..79ceaf6f 100644 --- a/demo/index.php +++ b/demo/index.php @@ -12,10 +12,4 @@ $smarty->assign("Class",array(array("A","B","C","D"), array("E", "F", "G", "H"), $smarty->display("./templates/index.tpl"); - -function insert_paginate() -{ - echo "test paginate\n"; -} - ?> diff --git a/demo/templates/index.tpl b/demo/templates/index.tpl index b1677583..17c86bcb 100644 --- a/demo/templates/index.tpl +++ b/demo/templates/index.tpl @@ -1,14 +1,17 @@ -{config_load file=test.conf section="my foo"} +{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}
 Title: {#title#|capitalize}
+{if #bold#}{/if}
 
 
 the value of $SCRIPT_NAME is {$SCRIPT_NAME}
 
-{* A simple variable test *}
+{* A simple variable test. print $Name in uppercase *}
 hello, my name is {$Name|upper}
 
 My interests are:
@@ -22,16 +25,14 @@ My interests are:
 	none
 {/section}
 
-({$FirstName|@count})
-
-{insert name=paginate}
+

testing strip tags {strip} diff --git a/doc.sgm b/doc.sgm index bb225c1d..9a56f9f1 100644 --- a/doc.sgm +++ b/doc.sgm @@ -1762,4 +1762,13 @@ is the first week that has at least 4 days in the current year, and with Monday modifiers. + + CREDITS + + Monte Ohrt: Original idea an initial implementation, wrote the documentation. + + + Andrei Zmievski: Rewrote parser from scratch, added much functionality. + + diff --git a/index.php b/index.php index 83565f8a..79ceaf6f 100644 --- a/index.php +++ b/index.php @@ -12,10 +12,4 @@ $smarty->assign("Class",array(array("A","B","C","D"), array("E", "F", "G", "H"), $smarty->display("./templates/index.tpl"); - -function insert_paginate() -{ - echo "test paginate\n"; -} - ?> diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 1b21e404..3e1610c7 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -7,6 +7,7 @@ * * Andrei Zmievski * parsing engine rewrite and a lot more + * Version: 1.0 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/templates/index.tpl b/templates/index.tpl index b1677583..17c86bcb 100644 --- a/templates/index.tpl +++ b/templates/index.tpl @@ -1,14 +1,17 @@ -{config_load file=test.conf section="my foo"} +{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}
 Title: {#title#|capitalize}
+{if #bold#}{/if}
 
 
 the value of $SCRIPT_NAME is {$SCRIPT_NAME}
 
-{* A simple variable test *}
+{* A simple variable test. print $Name in uppercase *}
 hello, my name is {$Name|upper}
 
 My interests are:
@@ -22,16 +25,14 @@ My interests are:
 	none
 {/section}
 
-({$FirstName|@count})
-
-{insert name=paginate}
+

testing strip tags {strip}

- + This is a test
- + This is a test