Outputting HTML and Templates

Big Word

Template: Text designed to be the basis for final text or content after being processed.

there's usually some specific template language, so the template system knows how to replace placeholders with real values.

The Code

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

http.createServer(function(req, res) {

    res.writeHead(200, { 'Content-Type': 'text/html' });
    var html = fs.readFileSync(__dirname + '/index.htm', 'utf8');
    var message = 'Hello world...';
    html = html.replace('{Message}', message);
    res.end(html);

}).listen(1337, '127.0.0.1');

results matching ""

    No results matching ""