EJS呈现HTML [英] EJS rendering HTML

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

问题描述

我在Express和MongoDB上有一个简单的博客应用程序,使用EJS呈现数据。

I've got a simple blog app on Express and MongoDB, using EJS to render my data.

我的问题是我希望将此样式设置为以下段落:

The problem I have is I want this to be styled like a paragraph:

<div class="show-post__content">

   <%= post.body %>

 </div>

post.body的内容为:'< p> Hello在那里,这是一条新帖子。< / p>'

The content of the post.body is: '<p>Hello there, this is a new post.</p>'

但它的呈现方式如下:

如果图片不起作用,则显示为可见的括号,而不是看起来像实际的html p标签(如果有任何意义的话)...
有人知道如何解决这个问题吗?

If the picture doesn't work, it's showing up with the brackets visible, rather than looking like an actual html p tag if that makes any sense... Does anyone know how to get around this?

非常感谢,

Raph

推荐答案

我知道了:

<div class="show-post__content">

   <%- post.body %>

 </div>

就是答案。

感谢您的光临!

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

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