| 148 |
lars |
1 |
Math {#language.math}
|
|
|
2 |
====
|
|
|
3 |
|
|
|
4 |
Math can be applied directly to variable values.
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
{$foo+1}
|
|
|
8 |
|
|
|
9 |
{$foo*$bar}
|
|
|
10 |
|
|
|
11 |
{* some more complicated examples *}
|
|
|
12 |
|
|
|
13 |
{$foo->bar-$bar[1]*$baz->foo->bar()-3*7}
|
|
|
14 |
|
|
|
15 |
{if ($foo+$bar.test%$baz*134232+10+$b+10)}
|
|
|
16 |
|
|
|
17 |
{$foo|truncate:"`$fooTruncCount/$barTruncFactor-1`"}
|
|
|
18 |
|
|
|
19 |
{assign var="foo" value="`$foo+$bar`"}
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
|
23 |
> **Note**
|
|
|
24 |
>
|
|
|
25 |
> Although Smarty can handle some very complex expressions and syntax,
|
|
|
26 |
> it is a good rule of thumb to keep the template syntax minimal and
|
|
|
27 |
> focused on presentation. If you find your template syntax getting too
|
|
|
28 |
> complex, it may be a good idea to move the bits that do not deal
|
|
|
29 |
> explicitly with presentation to PHP by way of plugins or modifiers.
|