fenom/docs/en/tags/extends.md

71 lines
1.2 KiB
Markdown
Raw Permalink Normal View History

2016-04-13 11:34:38 +03:00
Tag {extends}
2016-04-12 12:28:57 +03:00
=============
2013-02-15 12:17:23 +04:00
2016-04-12 12:28:57 +03:00
`{extends}` tags are used in child templates in template inheritance for extending parent templates.
The `{extends}` tag must be on before any block.
Also if a child template extends a parent template with the `{extends}` tag it may contain only `{block}` tags. Any other template content is ignored.
2013-02-15 12:17:23 +04:00
### {extends}
2013-02-19 09:51:33 +04:00
```smarty
{extends 'parent.tpl'}
```
2013-02-15 12:17:23 +04:00
### {block}
2013-02-19 09:51:33 +04:00
```smarty
{block 'bk2'}content 2{/block}
2013-03-15 00:57:28 +04:00
```
2013-02-19 09:51:33 +04:00
2013-02-15 12:17:23 +04:00
### {use}
Import the blocks defined in another file. Specifying blocks in this template will override those from the other file.
2013-02-15 12:17:23 +04:00
2013-02-19 09:51:33 +04:00
```smarty
2016-04-12 12:28:57 +03:00
{use 'blocks.tpl'} merge blocks from blocks.tpl template
2013-02-19 09:51:33 +04:00
2016-04-12 12:28:57 +03:00
{block 'alpha'} rewrite block alpha from blocks.tpl template, if it exists
...
{/block}
```
2013-02-19 09:51:33 +04:00
2013-02-15 12:17:23 +04:00
### {parent}
Uses the code from the block as defined in the parent.
2013-02-19 09:51:33 +04:00
```smarty
2016-04-12 12:28:57 +03:00
{extends 'parent.tpl'}
{block 'header'}
2013-02-19 09:51:33 +04:00
content ...
2016-04-12 12:28:57 +03:00
{parent} pase code from block 'header' from parent.tpl
2013-02-19 09:51:33 +04:00
content ...
{/block}
```
2013-02-15 12:17:23 +04:00
2016-04-12 12:28:57 +03:00
### {paste}
Pastes the code of any block
2016-04-12 12:28:57 +03:00
```smarty
{block 'b1'}
...
{/block}
{block 'b2'}
...
{paste 'b1'} paste code from b1
{/block}
```
### {$.block}
Checks if clock exists
```smarty
{if $.block.header}
block header exists
{/if}
```