Phalcon Volt将html代码转换为字符串
我有数据库中的html代码,我正试图将其打印为Phalcon Volt将html代码转换为字符串,html,phalcon,volt,Html,Phalcon,Volt,我有数据库中的html代码,我正试图将其打印为{{{blog.content}。但它呈现为字符串,并显示所有html标记等。如何使其呈现为html 它看起来像: <p>I am writing my blog post here to show everyone that I can do such things as this: <span style="font-weight: bold; font-family: Impact; font-size: 36px;">
{{{blog.content}
。但它呈现为字符串,并显示所有html标记等。如何使其呈现为html
它看起来像:
<p>I am writing my blog post here to show everyone that I can do such things as this: <span style="font-weight: bold; font-family: Impact; font-size: 36px;">adsdsfadsf </span><span style="font-size: 11px; background-color: yellow;">and also like this one</span></p>
我在这里写博文,向大家展示我可以做这样的事情:adsdfadsf,也可以做这样的事情
htmltags不应该是可见的。上面的行应该呈现为html。这意味着粗体部分的例子;应为粗体。1)Create Elements.php(库或插件都相同)
namespace YourAppNameSpace;
use Phalcon\Config;
class Elements extends \Phalcon\Mvc\User\Plugin
{
public function decodeString($string)
{
return html_entity_decode($string);
}
}
2) 将Elements.php添加到服务中
$di->set('element', function () {
return new YourAppNameSpace\Elements();
});
3) 在Volt文件中,尝试此
{{ element.decodeString(blog.content) }}
希望它能起作用……) 你能添加一个例子吗?我添加了一个例子。当你
var_dump(blog)
,你会得到什么?@JamesFenwick,它是伏特。我怎样才能转储它?{{dump(blog}}或者从控制器中临时删除volt文件和var_转储。我已经添加了函数my existing helper。谢谢!