ほとんどの 関数 には、 それらの動作を指定したり修正するための属性があります。Smarty 関数の属性は HTML の属性にかなり近いものです。静的な値はクォートで囲む必要はありませんが、 リテラル文字列であるべきです。変数を使う場合はクォートで囲んではいけません。 PHP の関数の結果やプラグインの結果、複雑な計算式なども使うことができます。
いくつかの属性は、boolean 値 (TRUE あるいは FALSE) を必要とします。
これらの値は、true あるいは
false を指定する事ができます。
属性に何も値を代入しない場合のデフォルトは、boolean の true です。
Example 3.4. 関数の属性の構文
{include file="header.tpl"}
{include file="header.tpl" nocache} // nocache=true と等価
{include file="header.tpl" attrib_name="attrib value"}
{include file=$includeFile}
{include file=#includeFile# title="My Title"}
{assign var=foo value={counter}} // プラグインの結果
{assign var=foo value=substr($bar,2,5)} // PHP の関数の結果
{assign var=foo value=$bar|strlen} // 修飾子の使用
{assign var=foo value=$buh+$bar|strlen} // より複雑な演算
{html_select_date display_days=true}
{mailto address="smarty@example.com"}
<select name="company_id">
{html_options options=$companies selected=$company_id}
</select>
Smarty では非常に複雑な演算や構文を処理することもできますが、 テンプレートの構文は必要最小限にして表示内容に注力することをお勧めします。 もしテンプレートの構文が複雑になりすぎてきたと感じたら、 表示内容に直接関係のない部分をプラグインや修飾子として PHP 側に追い出すとよいでしょう。