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>
!{article}
Shweet, thanks man, how did you know? Where can I find more of the syntax?
In the jade readme.
On Wed, 28 Mar 2012 08:00:29 -0700, Andrew Quan [email protected] wrote:
Shweet, thanks man, how did you know? Where can I find more of the syntax?
Ah, figures, thanks again wereHamster.
Most helpful comment