What is Smarty?
Why use it?
Use Cases and Work Flow
Syntax Comparison
Template Inheritance
Best Practices
Crash Course
You may use the Smarty logo according to the trademark notice.
For sponsorship, advertising, news or other inquiries, contact us at:
演算は、変数の値に直接適用されます。
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`"}
Smarty では非常に複雑な演算や構文を処理することもできますが、 テンプレートの構文は必要最小限にして表示内容に注力することをお勧めします。 もしテンプレートの構文が複雑になりすぎてきたと感じたら、 表示内容に直接関係のない部分をプラグインや修飾子として PHP 側に追い出すとよいでしょう。