テンプレートファイル(*.tpl)に {$変数名|escape}と書けば htmlspecialchars を呼んでくれますが、{$変数名}と書けば htmlspecialchars を呼び出しません。
~config.php~
setTemplateDir('./templates');
$smarty->setCacheDir('./cache');
$smarty->setCompileDir('./templates_c');
$smarty->setConfigDir('./configs');
$message = '変数のテスト';
$smarty->assign('text', $message);
$smarty->display('index.tpl');
[codehtml]
{$text|escape}
{$text|escape}
[/code]
Smartyが生成したPHPファイル
_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 }
}