2023-02-05 23:14:10 +01:00
|
|
|
# Basic Syntax
|
2021-12-03 11:59:22 +01:00
|
|
|
|
2021-12-03 16:51:08 +01:00
|
|
|
A simple Smarty template could look like this:
|
2023-02-03 17:54:00 +01:00
|
|
|
```smarty
|
2021-12-03 16:51:08 +01:00
|
|
|
<h1>{$title|escape}</h1>
|
|
|
|
<ul>
|
|
|
|
{foreach $cities as $city}
|
|
|
|
<li>{$city.name|escape} ({$city.population})</li>
|
|
|
|
{foreachelse}
|
|
|
|
<li>no cities found</li>
|
|
|
|
{/foreach}
|
|
|
|
</ul>
|
|
|
|
```
|
|
|
|
|
2021-12-03 11:59:22 +01:00
|
|
|
All Smarty template tags are enclosed within delimiters. By default
|
|
|
|
these are `{` and `}`, but they can be
|
2023-02-05 23:14:10 +01:00
|
|
|
[changed](../../programmers/api-variables/variable-left-delimiter.md).
|
2021-12-03 11:59:22 +01:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
2021-12-03 16:51:08 +01:00
|
|
|
The basis components of the Smarty syntax are:
|
2023-02-05 23:14:10 +01:00
|
|
|
|
|
|
|
- [Comments](language-syntax-comments.md)
|
|
|
|
- [Variables](language-syntax-variables.md)
|
2023-05-01 23:25:42 +02:00
|
|
|
- [Operators](language-syntax-operators.md)
|
2023-02-05 23:14:10 +01:00
|
|
|
- [Functions](language-syntax-functions.md)
|
|
|
|
- [Attributes](language-syntax-attributes.md)
|
|
|
|
- [Quotes](language-syntax-quotes.md)
|
|
|
|
- [Escaping](language-escaping.md)
|