I am new to node.js platoform. By default it uses jade as its template engine.Is there any way to use simple html tags instead of jade?
Asked
Active
Viewed 344 times
0
-
1possible duplicate of [node.js - what are the advantages of using jade](http://stackoverflow.com/questions/11344346/node-js-what-are-the-advantages-of-using-jade) – gherkins Sep 03 '13 at 08:09
-
Also http://stackoverflow.com/questions/17866289/html-in-express-and-node-js – Jonathan Lonowski Sep 03 '13 at 08:38
-
i would recommand to stick to jade, it makes writing html a lot faster and the source also looks cleaner... – supernova Sep 03 '13 at 10:55
2 Answers
0
Yep, it is possible:
var serverHTML = function(res) {
res.writeHead(200, {'Content-Type': 'text/html'});
var body = '<html>' +
'<head>' +
'<title>Page</title>' +
'</head>' +
'<body >' +
'<center><h1>Hello World</h1></center>' +
'</body>' +
'</html>';
res.end(body + '\n');
}
var http = require('http');
http.createServer(function (req, res) {
serverHTML(res);
}).listen(1337, '127.0.0.1');
console.log('Server running at 127.0.0.1:1337/');
However, using of template language brings a lot of benefits, like
- putting the templates in different files
- adding content
- using nested templates
If you use pure html you should deal with this by yourself.
There are of course template engines which uses html as base. For example https://github.com/paularmstrong/swig/

Krasimir
- 13,306
- 3
- 40
- 55
0
You ask "Is there any way to use simple html tags instead of jade?"
jade uses simple html tags. It just doesn't make you repeat them
blahvs
div blah

Jim Mack
- 1,437
- 11
- 16