diff options
| author | Uwe.Tews <uwe.tews@localhost> | 2009-08-28 18:32:31 +0000 |
|---|---|---|
| committer | Uwe.Tews <uwe.tews@localhost> | 2009-08-28 18:32:31 +0000 |
| commit | a13ae6628c652f9f94950b10846efcbe5341ed49 (patch) | |
| tree | 46a06844db17f63105928debfc909e2f8b570be5 /demo | |
| parent | 8c48521260888143382e342c62926b37fe96b8f4 (diff) | |
| download | smarty-a13ae6628c652f9f94950b10846efcbe5341ed49.tar.gz smarty-a13ae6628c652f9f94950b10846efcbe5341ed49.tar.bz2 smarty-a13ae6628c652f9f94950b10846efcbe5341ed49.zip | |
- Fix on line breaks inside {if} tags
Diffstat (limited to 'demo')
| -rw-r--r-- | demo/index.php | 86 | ||||
| -rw-r--r-- | demo/index_php_template.php | 48 | ||||
| -rw-r--r-- | demo/templates/footer.tpl | 2 | ||||
| -rw-r--r-- | demo/templates/header.tpl | 6 | ||||
| -rw-r--r-- | demo/templates/index.tpl | 82 |
5 files changed, 176 insertions, 48 deletions
diff --git a/demo/index.php b/demo/index.php index b3fbd4d3..fc280888 100644 --- a/demo/index.php +++ b/demo/index.php @@ -1,48 +1,38 @@ -<?php -/** -* Test script for PHP template -* @author Monte Ohrt <monte at ohrt dot com> -* @package SmartyTestScripts -*/ -require('../libs/Smarty.class.php'); -ini_set('short_open_tag','1'); - - class Person -{ - private $m_szName; - private $m_iAge; - - public function setName($szName) - { - $this->m_szName = $szName; - return $this; // We now return $this (the Person) - } - - public function setAge($iAge) - { - $this->m_iAge = $iAge; - return $this; // Again, return our Person - } - - public function introduce() - { - return 'Hello my name is '.$this->m_szName.' and I am '.$this->m_iAge.' years old.'; - } -} - -$smarty = new Smarty(); -$smarty->force_compile = false; -$smarty->caching = false; -$smarty->caching_lifetime = 10; - -$smarty->assign('foo','<bar>'); - -$person = new Person; - -$smarty->assign('person',$person); - -$smarty->assign('array',array('a'=>array('aa'=>'This is a long string'),'b'=>2)); - -$smarty->display('php:index_view.php'); - -?> +<?php
+ function _get_time()
+ {
+ $_mtime = microtime();
+ $_mtime = explode(" ", $_mtime);
+ return (double)($_mtime[1]) + (double)($_mtime[0]);
+ }
+
+$start=_get_time();
+require('../libs/Smarty.class.php');
+
+$smarty = new Smarty;
+
+
+
+//$smarty->force_compile = true;
+//$smarty->debugging = true;
+$smarty->caching = true;
+$smarty->caching_lifetime = 120;
+
+
+
+$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("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"),
+ array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")));
+
+$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');
+echo _get_time()-$start;
+?>
diff --git a/demo/index_php_template.php b/demo/index_php_template.php new file mode 100644 index 00000000..b3fbd4d3 --- /dev/null +++ b/demo/index_php_template.php @@ -0,0 +1,48 @@ +<?php +/** +* Test script for PHP template +* @author Monte Ohrt <monte at ohrt dot com> +* @package SmartyTestScripts +*/ +require('../libs/Smarty.class.php'); +ini_set('short_open_tag','1'); + + class Person +{ + private $m_szName; + private $m_iAge; + + public function setName($szName) + { + $this->m_szName = $szName; + return $this; // We now return $this (the Person) + } + + public function setAge($iAge) + { + $this->m_iAge = $iAge; + return $this; // Again, return our Person + } + + public function introduce() + { + return 'Hello my name is '.$this->m_szName.' and I am '.$this->m_iAge.' years old.'; + } +} + +$smarty = new Smarty(); +$smarty->force_compile = false; +$smarty->caching = false; +$smarty->caching_lifetime = 10; + +$smarty->assign('foo','<bar>'); + +$person = new Person; + +$smarty->assign('person',$person); + +$smarty->assign('array',array('a'=>array('aa'=>'This is a long string'),'b'=>2)); + +$smarty->display('php:index_view.php'); + +?> diff --git a/demo/templates/footer.tpl b/demo/templates/footer.tpl new file mode 100644 index 00000000..c9e0d2e1 --- /dev/null +++ b/demo/templates/footer.tpl @@ -0,0 +1,2 @@ +</BODY>
+</HTML>
diff --git a/demo/templates/header.tpl b/demo/templates/header.tpl new file mode 100644 index 00000000..0df5a982 --- /dev/null +++ b/demo/templates/header.tpl @@ -0,0 +1,6 @@ +<HTML>
+<HEAD>
+{popup_init src="/javascripts/overlib.js"}
+<TITLE>{$title} - {$Name}</TITLE>
+</HEAD>
+<BODY bgcolor="#ffffff">
diff --git a/demo/templates/index.tpl b/demo/templates/index.tpl new file mode 100644 index 00000000..03623e8e --- /dev/null +++ b/demo/templates/index.tpl @@ -0,0 +1,82 @@ +{config_load file="test.conf" section="setup"}
+{include file="header.tpl" title=foo}
+
+<PRE>
+
+{* bold and title are read from the config file *}
+{if #bold#}<b>{/if}
+{* capitalize the first letters of each word of the title *}
+Title: {#title#|capitalize}
+{if #bold#}</b>{/if}
+
+The current date and time is {$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}
+
+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 <b>{$Name}</b>
+
+variable modifier example of {ldelim}$Name|upper{rdelim}
+
+<b>{$Name|upper}</b>
+
+
+An example of a section loop:
+
+{section name=outer
+loop=$FirstName}
+{if $smarty.section.outer.index is odd by 2}
+ {$smarty.section.outer.rownum} . {$FirstName[outer]} {$LastName[outer]}
+{else}
+ {$smarty.section.outer.rownum} * {$FirstName[outer]} {$LastName[outer]}
+{/if}
+{sectionelse}
+ none
+{/section}
+
+An example of section looped key values:
+
+{section name=sec1 loop=$contacts}
+ phone: {$contacts[sec1].phone}<br>
+ fax: {$contacts[sec1].fax}<br>
+ cell: {$contacts[sec1].cell}<br>
+{/section}
+<p>
+
+testing strip tags
+{strip}
+<table border=0>
+ <tr>
+ <td>
+ <A HREF="{$SCRIPT_NAME}">
+ <font color="red">This is a test </font>
+ </A>
+ </td>
+ </tr>
+</table>
+{/strip}
+
+</PRE>
+
+This is an example of the html_select_date function:
+
+<form>
+{html_select_date start_year=1998 end_year=2010}
+</form>
+
+This is an example of the html_select_time function:
+
+<form>
+{html_select_time use_24_hours=false}
+</form>
+
+This is an example of the html_options function:
+
+<form>
+<select name=states>
+{html_options values=$option_values selected=$option_selected output=$option_output}
+</select>
+</form>
+
+{include file="footer.tpl"}
|
