veinhorn
veinhorn

Reputation: 2403

How to include html code into Jade file?

I get from database some html:

<span style="text-decoration: underline; font-style: italic; font-weight: bold;">Hello Summernote</span>

How can I add this html into div using Jade? When I tried to add it I got something like that.

<div>"<span style="text-decoration: underline; font-style: italic; font-weight: bold;">Hello Summernote</span>"</div>

Upvotes: 2

Views: 854

Answers (1)

r0-
r0-

Reputation: 2498

Jade offers the ability to render 'regular' html inside a template. In your router (in the example it's express):

router.get('/', function (req, res) {
    res.render('default', {text: content});
});

text is in this case the html from your database. In jade you have to wrap your element:

#content
        p !{text}

!{} will stop the rendering process of the content and use the plain html from your database. The p tag is just an example to display it.

Upvotes: 5

Related Questions