|
You are here: Home / SimpleTemplate Reference |
SimpleTemplate ReferenceMarch 28, 2005 Tag Commands{variable_name}Performs a variable replacement, replacing the tag with the specified variable. Variables are specified by name alone, and optionally by object and name separated by a forward-slash (/). Examples
{some_var}
{obj/some_var}
{cgi/foo}
{session/username}
{alt}Uses the saf.Misc.Alt package to alternate between values. Typically used to alternate the colours of table rows. Example
{alt odd even}
<table border="0" cellpadding="3" cellspacing="1">
{loop obj.some_list}
<tr class="{alt/next}">
<td>{loop/_key}</td>
<td>{loop/_value}</td>
<td>{alt/current}</td>
</tr>
{end loop}
</table>
{alt/reset}
{loop range (1, 5)}
{alt/next}<br />
{end loop}
{box}Embeds a Sitellite box into the template. Box parameters are specified using a URL syntax. Dynamic parameters can be specified using square braces ([]) to inline sub-tags. Examples
{box sitellite/nav/breadcrumb}
{box sitepoll/display}
{box news/sidebar?sec=Sports}
{box news/sidebar?sec=[cgi/section]}
{exec}Executes the specified expression, but does not output the results. Examples
{exec obj.date = date ('F j, Y')}
{exec loader_import ('saf.HTML')}
{filter}Changes the function used to filter variable replacements in the template. The default filter is the "htmlentities", which calls the htmlentities_compat() function defined in saf.Functions. Other options are any valid function name, including PHP functions as well as your custom-written functions. The filter name "none" is also available to allow unfiltered variable output. Examples
{filter urlencode}{cgi/foo}{end filter}
{filter strtoupper}{title}{end filter}
{filter none}{body}{end filter}
{form}Embeds a Sitellite form into the template. Example
{form myapp/contact}
{if}Evaluates the specified PHP Shorthand expression to determine whether to display or exclude the template block the "if" statement surrounds. An alias "else" is created after each "if", which can be used in the form {if else}{end if} to display an alternate block of the template. Examples
{if obj.foo eq 'bar'}
foo is bar
{end if}
{if not empty (obj.foo)}
{foo}
{end if}
{if else}
foo is unspecified.
{end if}
{inc}Includes an external file into the template. Example
{inc foo.txt}
{info}Outputs the result of the specified expression passed to PHP's print_r() function and automatically wrapped in <pre></pre> tags. This command is useful for testing expressions. Example
{info obj.some_var}
{intl}Replaces the specified text with a call to the intl_get() function from the saf.I18n package. Example
{intl Hello}
{loop}Loops through the specified list. Assigns each item to the object "loop" during its iteration. In nested loops, the parent loop's current item can be accessed via "parent". Additionally, the following properties are set for each item:
Examples
{loop range (1, 10)}
index: {loop/_index},
key: {loop/_key},
value: {loop/_value},
total: {loop/_total}
{end loop}
<table border="2">
{loop range (1, 5)}
<tr>
{loop range (1, 5)}
<td>{parent/_value}, {loop/_value}</td>
{end loop}
</tr>
{end loop}
</table>
<ul>
{loop db_fetch_array ('select id, title from sitellite_page limit 5')}
<li><a href="{site/prefix}/index/{loop/id}">{loop/title}</a></li>
{end loop}
</ul>
<table border="2">
{loop db_fetch_array ('select * from sitellite_mime_type limit 10')}
<tr>
{loop loop._properties}
<td>{loop/_value}</td>
{end loop}
</tr>
{end loop}
</table>
{php}Executes the specified expression and outputs the results. Example
{php date ('F j, Y')}
{spt}Includes an external file into the template and parses it as a SimpleTemplate file as well. Example
{spt foo.spt}
|
|
Copyright © 2008, SIMIAN systems Inc. All rights reserved. Privacy policy Some of the icons on this site were created by the Gnome Project. |