使用法 (
{if:variable}
, {if:method()}
)
if 文を作成します。引数には変数あるいはメソッドを指定します。 最後は {end:} 文で閉じる必要があります。また、{else:} を使用することもできます。
if 用の変数の設定
class example {
function showDog() {
return true;
}
function output() {
$this->showStuff = true;
.........
$template->outputObject($this);
}
}
テンプレート
{if:showStuff}Hello{end:}
{if:showDog()}Doggy{end:}
コンパイルされたテンプレート
<?php if ($t->showStuff) { ?>Hello<?php } ?>
<?php if ($t->showDog()) { ?>Doggy<?php } ?>
出力
Hello
Doggy