mirror of
https://github.com/fenom-template/fenom.git
synced 2023-08-10 21:13:07 +03:00
Add doc for {insert} and {switch}
This commit is contained in:
parent
ecc842cc04
commit
de4fcad602
@ -42,9 +42,9 @@ Documentation
|
||||
* [if](./tags/if.md), `elseif` and `else`
|
||||
* [foreach](./tags/foreach.md), `foreaelse`, `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)
|
||||
* [include](./tags/include.md)
|
||||
* [include](./tags/include.md), `insert`
|
||||
* [extends](./tags/extends.md), `use`, `block` and `parent`
|
||||
* [filter](./tags/filter.md)
|
||||
* [ignore](./tags/ignore.md)
|
||||
|
@ -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}
|
||||
```
|
||||
|
@ -5,9 +5,36 @@ Tag {switch}
|
||||
{switch <condition>}
|
||||
{case <value1>}
|
||||
...
|
||||
{case <value2>}
|
||||
{case <value2>, <value3>, ...}
|
||||
...
|
||||
{case <value3>}
|
||||
...
|
||||
{default}
|
||||
...
|
||||
{/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
|
||||
```
|
Loading…
Reference in New Issue
Block a user