通过Smarty从PHP数组渲染HTML

时间:2013-10-14 20:54:44

标签: php html arrays tags smarty

以下是Smarty模板文件的内容......

{foreach from=$productcustomfields item=customfield}
<tr>
  <td class="fieldarea">{$customfield.name}:</td>
  <td>{$customfield.value}</td>
</tr>
{/foreach}

在屏幕上呈现{$ customfield.value}时,该数组值中的任何HTML标记都会在浏览器中显示为纯文本。我怎样才能让Smarty实际呈现HTML标签而不是将它们作为文字文本?

例如,如果$ customfield.value的值为...

<strong>Hello</strong>

在浏览器中看起来就像那样,而不是像 Hello 那样。

1 个答案:

答案 0 :(得分:1)

尝试

{$customfield.value nofilter}

(见reference