| 991 |
lars |
1 |
# Basic Syntax
|
|
|
2 |
|
|
|
3 |
A simple Smarty template could look like this:
|
|
|
4 |
```smarty
|
|
|
5 |
<h1>{$title|escape}</h1>
|
|
|
6 |
<ul>
|
|
|
7 |
{foreach $cities as $city}
|
|
|
8 |
<li>{$city.name|escape} ({$city.population})</li>
|
|
|
9 |
{foreachelse}
|
|
|
10 |
<li>no cities found</li>
|
|
|
11 |
{/foreach}
|
|
|
12 |
</ul>
|
|
|
13 |
```
|
|
|
14 |
|
|
|
15 |
All Smarty template tags are enclosed within delimiters. By default
|
|
|
16 |
these are `{` and `}`, but they can be
|
|
|
17 |
[changed](../../programmers/api-variables/variable-left-delimiter.md).
|
|
|
18 |
|
|
|
19 |
For the examples in this manual, we will assume that you are using the
|
|
|
20 |
default delimiters. In Smarty, all content outside of delimiters is
|
|
|
21 |
displayed as static content, or unchanged. When Smarty encounters
|
|
|
22 |
template tags, it attempts to interpret them, and displays the
|
|
|
23 |
appropriate output in their place.
|
|
|
24 |
|
|
|
25 |
The basis components of the Smarty syntax are:
|
|
|
26 |
|
|
|
27 |
- [Comments](language-syntax-comments.md)
|
|
|
28 |
- [Variables](language-syntax-variables.md)
|
|
|
29 |
- [Functions](language-syntax-functions.md)
|
|
|
30 |
- [Attributes](language-syntax-attributes.md)
|
|
|
31 |
- [Quotes](language-syntax-quotes.md)
|
|
|
32 |
- [Math](language-math.md)
|
|
|
33 |
- [Escaping](language-escaping.md)
|