Files
development/www/lib/smarty-4.1.0/docs/designers/language-basic-syntax.md
Clemens Schwaighofer f8ee6044f9 Upgrade from Smarty 3 to Smarty 4 to be PHP 8.1 compatible
Remove all Smarty4 dedicated tests, all are done in the same test file
like before
2022-04-06 15:19:06 +09:00

1.2 KiB

Basic Syntax

A simple Smarty template could look like this:

<h1>{$title|escape}</h1>
<ul>
    {foreach $cities as $city}
        <li>{$city.name|escape} ({$city.population})</li>
    {foreachelse}
        <li>no cities found</li>        
    {/foreach}
</ul>

All Smarty template tags are enclosed within delimiters. By default these are { and }, but they can be changed.

For the examples in this manual, we will assume that you are using the default delimiters. In Smarty, all content outside of delimiters is displayed as static content, or unchanged. When Smarty encounters template tags, it attempts to interpret them, and displays the appropriate output in their place.

The basis components of the Smarty syntax are: