Hey everyone,
I want to render some HTML in a Jade view which was passed through a variable.
It is currently rendering as escaped HTML and not plain HTML, how do I go about explicitly rendering it as plain HTML?
I understand it may be a bad security practice but what if it is plain markdown text that gets converted to HTML at render time?
// in the route
res.render('index', { title: 'Lorem Ipsum', article: '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>' });
// jade view
h1= title
#{article}
The current output:
<h1>Lorem Ipsum</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
I would like it to be rendered as:
<h1>Lorem Ipsum</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
Markdown scenario:
// in the route
res.render('index', { title: 'Lorem Ipsum', article: md('Lorem ipsum dolor sit amet, consectetur adipiscing elit.') });
I would like it to be rendered as:
<h1>Lorem Ipsum</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
1 thought on “Explicitly render a string of HTML or markdown in Jade”
Comments are closed.