我希望 smarty 显示 html 变量内容,就像它是 html 文件的一部分一样,所以我使用“unescape”修饰符,就像显示 here 一样:
<div id="add">{if $add}{$add|unescape:"html"}{/if}</div>
但我得到:
Fatal error: Smarty error: [in xxx.html line 20]: [plugin] modifier 'unescape' is not implemented (core.load_plugins.php, line 118) in
XXX/inc/lib/Smarty/Smarty.class.php on line 1095
我的插件目录在正确的位置:
Smarty$ ls
Config_File.class.php Smarty.class.php Smarty_Compiler.class.php debug.tpl error_log internals plugins
什么可能是错的,我该如何做我想做的事?
最佳答案
尝试通过 php 处理它:
<div id="add">
{if $add}
{php}
echo html_entity_decode($add);
{/php}
{/if}
</div>
您可以使用 ojita 函数来满足您的需要,或者您可以使用 htmlspecialchars_decode()
或 mb_convert_encoding()
作为 Smarty html_entity_decode 函数的建议。关于php - Smarty 错误 : modifier 'unescape' is not implemented,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29869923/