boolean
HTML_Template_IT::loadTemplatefile
(
string
$filename
, boolean
$removeUnknownVariables
= = true
, boolean
$removeEmptyBlocks
= = true
)
ファイルからテンプレートを読み込み、 ブロックおよび変数の内部リストを作成します。
string $filename
-
ロードするファイル
boolean $removeUnknownVariables
-
TRUE であれば、置換されなかったブロック内のプレースホルダは除去されます。
boolean $removeEmptyBlocks
-
TRUE であれば、タッチされなかったブロックは除去されます。
ブロックをタッチするには HTML_Template_IT::touchBlock()
を使用します。
boolean
-
Returns TRUE on success, FALSE on failure.
テンプレートファイル main.tpl.htm
<html> <body> User {USERNAME} logged in successfull as {ROLE}. </body> </html>
$removeUnknownVariables
= FALSE
で実行するスクリプト
<?php
require_once 'HTML/Template/IT.php';
$tpl = new HTML_Template_IT('.');
$tpl->loadTemplatefile ('main.tpl.htm', false, false);
$tpl->setVariable ('USERNAME', 'foo');
// プレースホルダ ROLE が設定されていません
$tpl->show();
?>
出力
$removeUnknownVariables
= TRUE
で実行するスクリプト
<?php
require_once 'HTML/Template/IT.php';
$tpl = new HTML_Template_IT('.');
$tpl->loadTemplatefile ('main.tpl.htm', true, true);
$tpl->setVariable ('USERNAME', 'foo');
// プレースホルダ ROLE が設定されていませんが、
// $removeUnknownVariables が true に設定されています
$tpl->show();
?>
出力
This function can not be called statically.