VictorArcas
VictorArcas

Reputation: 630

Return raw html with node (just html into a var)

I'm trying to use jade via node, but when I run this code I get the html parsed by jade beetwen 'pre' tags.

var http = require('http');
var jade = require('jade');

http.createServer(function(request, response){
    response.writeHead(200, {'Content-Type': 'text/plain'});

    response.end(jade.renderFile('index.jade'));
}).listen(8124);

console.log('Server running at http://127.0.0.1:8124/');

How can I make node render raw html without scaping anything?

Upvotes: 0

Views: 491

Answers (1)

xaviert
xaviert

Reputation: 5932

To render HTML, you need to use 'Content-Type': 'text/html; charset=UTF-8'. Using text/plain will render the HTML as plain text (without interpretation) and will make it look as if the HTML was rendered between <pre></pre> tags.

Upvotes: 1

Related Questions