想要在mongodb中插入带有html标签的数据并在浏览器中呈现它 [英] Want to insert data with html tag in mongodb and render it on browser

查看:240
本文介绍了想要在mongodb中插入带有html标签的数据并在浏览器中呈现它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用mongoDB开发节点js。我能够在数据库中插入数据。我有大量内容要插入< p> < li> 标记。当我提取数据并在浏览器上呈现时,它只显示标签。我希望这个标签能够转化为其意义。
示例:

I am working on node js with mongoDB. I am able to insert data in database. I have large content to insert with some <p> and <li> tag. When i am fetching data and rendering it on browser it is showing with tag only. I want that tag to be convert in their meaning. Example:

<p>this is the content</p>

它也在浏览器上显示。
这应该转换为this is content。

It is showing same on browser also. this should convert in "this is content".

在视图页面上,我有以下代码。

On view page i have following code.

    {{#each doc}}
    <div class="content">
    {{this.content}}            
    </div>
    {{/each}}


推荐答案

您需要输出你的内容为原始html,否则模板引擎将会跳出你的html内容。

You need to output your content as raw html, or else the template engine will escape your html content.

看起来你正在使用句柄:使用三元 {{}}} 括号

Look like you are using handlebars: use the triple {{{ }}} brackets

{{#each doc}}
<div class="content">
{{{this.content}}}            
</div>
{{/each}}

这篇关于想要在mongodb中插入带有html标签的数据并在浏览器中呈现它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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