fenom/docs/tags/macro.md

31 lines
342 B
Markdown
Raw Normal View History

2013-02-21 22:47:24 +04:00
Tag {macro}
============
2013-02-23 13:29:20 +04:00
Declare macro
2013-02-21 22:47:24 +04:00
```smarty
2013-02-23 13:29:20 +04:00
{macro plus(x, y, z=0)}
x + y + z = {$x + $y + $z}
2013-02-21 22:47:24 +04:00
{/macro}
```
2013-02-23 13:29:20 +04:00
Invoke macro
2013-02-21 22:47:24 +04:00
```smarty
2013-02-23 13:29:20 +04:00
{macro.plus x=$num y=100}
2013-02-21 22:47:24 +04:00
```
2013-03-04 10:13:59 +04:00
### {import}
Import [macro](./macro.md) from another template
```smarty
{import 'math.tpl'}
```
```smarty
{import 'math.tpl' as math}
...
{math.plus x=5 y=100}
```