0

I'm playing around with Node.js and have connected to my mysql-database and are fetching some blog-records, but the contents are decoded html in the db. I can't seem to encode. I've tried it in the controller (i'm using express), and are trying it in the jade-view. Actually i have not a clue about best practices, but are anyway hacking through something. Some help would be appreciated.

In my index.jade:

var StringDecoder = require('string_decoder').StringDecoder;
var decoder = new StringDecoder('utf8');


extends layout

The problem lies somewhere with Jade (but where?):

From controller:

 res.render('index', { title: '<i>Express</i>', bloglist : rows });

The html tags is not showing correctly:

<i>Express</i>


block content
  h1= title
  p Welcome to #{title}

     div
      for blog in bloglist
        h3 #{blog.Title}
         p #{decoder.write(blog.Text)}
marko
  • 9,489
  • 16
  • 66
  • 88
  • what does console.log(blog.Text) output? – generalhenry Apr 16 '13 at 21:02
  • I can't remember where I read about this, but I think you don't need to htmlencode/decode as jade (is awesome) it does all this for you. I will try to find this article for you, so bare with... – Val Apr 18 '13 at 11:04
  • See if this question helps, as I can't seem to find that article ... http://stackoverflow.com/questions/10111232/how-to-make-jade-stop-html-encoding-element-attributes-and-produce-a-literal-st – Val Apr 18 '13 at 11:11

0 Answers0