Last Updated: February 25, 2016
·
1.319K
· eduardojmatos

Node, Jade, Asset-Rack and Templates

For use jade templates on client-side.

In package.json:

"dependencies": {
  "express": "*",
  "jade": "*",
  "asset-rack": "*"
}

Installing:

npm install

In your app.js (node app):

var assetRack = require('asset-rack');

var jadeAssets = new assetRack.JadeAsset({
  url: '/views/templates.js',
  dirname: './views/templates'
});

var app = express();

app.configure(function(){
    .
    .
    app.use(jadeAssets);
    .
    .
});

In your script.js, on client side:

var template = Templates['someTemplate']();
$('#someDiv').html( template );