Monday, 16 April 2012

Node.js: Templating with Plates

Plates is the templating library in flatiron. Plates binds data to markup. It's Javascript, Markup and JSON. It works in the browser and in node.js. All templates are actually valid HTML, with no special characters for value insertion. The relationship between tags and values is defined through object literals that are passed to Plates.bind:
You have to install plates before using it

Plates can be used in the program by requiring it.
var http = require('http'),
    plates = require(../lib/plates');

var server = http.createServer(function (req, res) {
    var userSpan = '<span id="spFirstName">Prajeesh</span>&nbsp;<span id="spLastName">Prathap</span>'
    var userHtml = '<div id="pnlLogin"></div>';

    var map = plates.Map();
    var content = plates.bind(userHtml, { 'pnlLogin': userSpan });


No comments:

Post a Comment