Add doc for {insert} and {switch}

This commit is contained in:
bzick 2013-08-30 10:26:17 +04:00
parent ecc842cc04
commit de4fcad602
3 changed files with 60 additions and 4 deletions

View File

@ -42,9 +42,9 @@ Documentation
* [if](./tags/if.md), `elseif` and `else` * [if](./tags/if.md), `elseif` and `else`
* [foreach](./tags/foreach.md), `foreaelse`, `break` and `continue` * [foreach](./tags/foreach.md), `foreaelse`, `break` and `continue`
* [for](./tags/for.md), `forelse`, `break` and `continue` * [for](./tags/for.md), `forelse`, `break` and `continue`
* [switch](./tags/switch.md), `case`, `default` and `break` * [switch](./tags/switch.md), `case`, `default`
* [cycle](./tags/cycle.md) * [cycle](./tags/cycle.md)
* [include](./tags/include.md) * [include](./tags/include.md), `insert`
* [extends](./tags/extends.md), `use`, `block` and `parent` * [extends](./tags/extends.md), `use`, `block` and `parent`
* [filter](./tags/filter.md) * [filter](./tags/filter.md)
* [ignore](./tags/ignore.md) * [ignore](./tags/ignore.md)

View File

@ -14,3 +14,32 @@ Tag {include} [RU]
``` ```
Все изменения переменных в подключаемом шаблоне не будут воздействовать на родительский шаблон. Все изменения переменных в подключаемом шаблоне не будут воздействовать на родительский шаблон.
### {insert}
The tag insert template template code instead self.
* No dynamic name allowed
* No variables as attribute allowed
For example,
```smarty
a: {$a}
{insert 'b.tpl'}
c: {$c}
```
b.tpl:
```
b: {$b}
```
Во время разбора шаблона код шаблона `b.tpl` будет вставлен в код шаблона `main.tpl` как есть:
```smarty
a: {$a}
b: {$b}
c: {$c}
```

View File

@ -5,9 +5,36 @@ Tag {switch}
{switch <condition>} {switch <condition>}
{case <value1>} {case <value1>}
... ...
{case <value2>} {case <value2>, <value3>, ...}
...
{case <value3>}
... ...
{default} {default}
... ...
{/switch} {/switch}
``` ```
For example,
```smarty
{switch $type}
{case 'new'}
It is new item
{case 'current', 'new'}
It is new or current item
{case 'current'}
It is current item
{case 'new'}
It is new item, again
{default}
I don't know the type {$type}
{/switch}
```
If `$type = 'new'` template outputs
```
It is new item
It is new or current item
It is new item, again
```