stop html entity replacing "<" with "&lt;"

54 views
Skip to first unread message

Tushar Kapila

unread,
Nov 5, 2014, 10:02:01 AM11/5/14
to keyst...@googlegroups.com
hi
I want to render page sections with html coming from the data base.

To test in my init function i have

     locals.intro = "my intro<b>bolder 2</b>";

On my jade template this gets rendered with the opening and closing angular brackets escaped  :

      &lt;/b&gt;

How do I stop this? Similarly for fields from the data base console.log shows the expected value like </b> but on the page its escaped,

Regards
Tushar Kapila

Luke Simpson

unread,
Nov 5, 2014, 1:56:03 PM11/5/14
to keyst...@googlegroups.com
Hello,

From the Jade tutorial page: http://jade-lang.com/tutorial/

"You can output raw text from JavaScript variables. Jade will also helpfully filter the text for you so it's safe from nasty HTML injection attacks...If you don't want Jade to filter your output, use != instead of =." 

Try using that in your template when you render the variable.

Luke
Reply all
Reply to author
Forward
0 new messages