<table>
{section name=index loop=$students}
{strip}
<tr bgcolor="{cycle values="#CCCCCC,#FFFFFF"}">
<td>{$students[index].firstname}
{$students[index].surname}</</td>
</tr>
{/strip}
{/section}
</table>
There are dozens of modifiers and functions that can be used to format output with Smarty as well. For instance, case and capitalisation can be enforced using the upper, lower and capitalize modifiers as shown here.
{"foobar"|upper}
{"foobar"|lower}
{"foobar"|capitalize}
There are also modifiers to truncate text, strip HTML tags, replace substrings and format dates. With the use of plugins, you can perform paging through query results and validate user input. If absolutely necessary, it is also possible to execute PHP code from within a template, although this tends to undermine the benefit of using templates as well as posing a risk to the application by exposing source code execution which is otherwise disabled by default.
Although it may seem awkward or even unnecessary to replace PHP code with Smarty code by using templates, it is important to remember that Smarty code simply modifies display logic and has no access to the underlying application or database logic. Thus, a front end developer can use Smarty logic to determine whether a login box should be displayed or a table row wrapped, but they cannot create a database query or access session variables, for instance. Keeping this fundamental separation of the roles of display and business rules is essential for keeping sophisticated web applications manageable.