Smartyで生成されたファイル

naohiro19
記事: 256
登録日時: 15年前
住所: 愛知県

Smartyで生成されたファイル

投稿記事 by naohiro19 » 9年前

Smartyはテンプレートファイル(*.tpl)に表示部分を書いて、*.phpに変数やデータベースの処理を書けばあとはなにもしなくてもSmartyが自動的にPHPファイルにコンパイルしてくれます。
テンプレートファイル(*.tpl)に {$変数名|escape}と書けば htmlspecialchars を呼んでくれますが、{$変数名}と書けば htmlspecialchars を呼び出しません。

~config.php~

CODE:

setTemplateDir('./templates');
$smarty->setCacheDir('./cache');
$smarty->setCompileDir('./templates_c');
$smarty->setConfigDir('./configs');

$message = '変数のテスト';
$smarty->assign('text', $message);


$smarty->display('index.tpl');
~index.tpl~
[codehtml]




{$text|escape}


{$text|escape}

[/code]

Smartyが生成したPHPファイル

CODE:

_decodeProperties($_smarty_tpl, array (
  'version' => '3.1.30',
  'unifunc' => 'content_57b90504991877_96915816',
  'has_nocache_code' => false,
  'file_dependency' => 
  array (
    '78e58defbdfea431750a09853da0fcf6e8876e0e' => 
    array (
      0 => 'C:\\xampp\\htdocs\\onebbs\\templates\\index.tpl',
      1 => 1471743230,
      2 => 'file',
    ),
  ),
  'includes' => 
  array (
  ),
),false)) {
function content_57b90504991877_96915816 (Smarty_Internal_Template $_smarty_tpl) {
?>



	
	tpl_vars['text']->value, ENT_QUOTES, 'UTF-8', true);?>



	tpl_vars['text']->value, ENT_QUOTES, 'UTF-8', true);?>


<?php }
}
最後に編集したユーザー naohiro19 on 2016年8月21日(日) 16:03 [ 編集 3 回目 ]

コメントはまだありません。