fenom/docs/en/tags/include.md

47 lines
849 B
Markdown
Raw Normal View History

2014-06-09 23:40:31 +04:00
Tag {include}
=============
2013-02-08 14:23:10 +04:00
`{include}` tags are used for including other templates in the current template. Any variables available in the current template are also available within the included template.
```smarty
{include "about.tpl"}
```
2014-06-09 23:40:31 +04:00
If you need to set yours variables for template list them in attributes.
2013-02-08 14:23:10 +04:00
```smarty
{include "about.tpl" page=$item limit=50}
2013-02-20 18:02:27 +04:00
```
2014-06-09 23:40:31 +04:00
All variables changed in child template has no affect to variables in parent template.
2013-08-30 10:26:17 +04:00
### {insert}
2013-09-02 17:40:58 +04:00
The tag insert template code instead self.
2013-08-30 10:26:17 +04:00
2014-06-09 23:40:31 +04:00
* No dynamic name allowed.
* No variables as attribute allowed.
* Increase performance because insert code as is in compilation time.
2013-08-30 10:26:17 +04:00
2013-09-02 17:40:58 +04:00
For example, main.tpl:
2013-08-30 10:26:17 +04:00
```smarty
a: {$a}
{insert 'b.tpl'}
c: {$c}
```
b.tpl:
```
b: {$b}
```
2014-06-09 23:40:31 +04:00
Code of `b.tpl` will be inserted into `main.tpl` as is:
2013-08-30 10:26:17 +04:00
```smarty
a: {$a}
b: {$b}
c: {$c}
```