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)}