Get Smarty

Donate

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Sites Using Smarty

Buy cheap glasses from Cheapglasses123.com and save up to 80%.

Where to buy prescription glasses? EyewearCanada.com is your best choice!

Visit www.sport-kick.com for cheap soccer cleats, sneakers and Soccer Jerseys updates

Advertisement

数学计算

变量值内可以直接进行数学计算。

Example 3.7. 数学计算例子


{$foo+1}

{$foo*$bar}

{* 更复杂的例子 *}

{$foo->bar-$bar[1]*$baz->foo->bar()-3*7}

{if ($foo+$bar.test%$baz*134232+10+$b+10)}

{$foo|truncate:"`$fooTruncCount/$barTruncFactor-1`"}

{assign var="foo" value="`$foo+$bar`"}

  

Note

虽然Smarty可以处理一些非常复杂的表达式和运算, 但最好还是保存模板的语法简洁,把焦点放在显示上。 如果你发现某部分模板代码过于复杂,一个好的方法是将这部分的代码放到插件或者修饰器内使用。

Comments
No comments for this page.

Advertisement