Smarty 显示原始 HTML [英] Smarty displays raw HTML

查看:31
本文介绍了Smarty 显示原始 HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将我的 HTML 字符串传递给 $content 变量并尝试显示它,在结果中我看到原始 HTML 标记而不是字符串标记.

I am passing my HTML string to the $content variable and trying to display it, in the result I see raw HTML tags instead of the string markup.

控制器:

$content = "<strong>Test markup</strong>";

index.tpl:

{$content} - 仅显示没有标记的原始变量内容:测试标记 测试标记的替代强>.

{$content} - displays just raw variable content without markup: <strong>Test markup</strong> INSTEAD of the Test markup.

当我在 index.tpl 中手动输入上述变量内容时,它工作得很好,所以它似乎是一些与变量相关的问题.

When I type manually the above variable content in the index.tpl then it works just fine so it seems to be some variable-related issue.

我尝试了什么:

{content|nofilter} - 确保它不是由 Smarty 的任何可变过滤器引起的.

{content|nofilter} - to be sure its not caused by any of the Smarty's variable filters.

有人可以帮我定位问题吗?

Could someone help me to localize the problem?

推荐答案

请尝试:

{$content|unescape:'html'}

更多详情:http://www.smarty.net/docs/en/language.modifier.unescape.tpl

这篇关于Smarty 显示原始 HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆