Smarty displays raw HTML

筅森魡賤 提交于 2020-12-13 03:43:04

问题


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.

Controller:

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

index.tpl:

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

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.

What have I tried:

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

Could someone help me to localize the problem?


回答1:


Please try:

{$content|unescape:'html'}

More details on: http://www.smarty.net/docs/en/language.modifier.unescape.tpl



来源:https://stackoverflow.com/questions/21242713/smarty-displays-raw-html

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!