tempistry

ultra light-weight registry for serializing javascript templates and applying pre/post render logic
Install
npm install tempistry
Uses temper for compilation, so supports the following rendering engines:
- jade
- ejs
- hogan.js
- mustache
- handlebars
Server Side
var tempistry = require('tempistry');
var templateString = tempistry.serialize('/my/templates/file.jade');
var clientJS = "var myTemplate = " + templateString;
You can also grab the full template data object that temper provides by passing true as the second param
var data = tempistry.serialize('/my/templates/file.jade', true);
Browserify Transform
If you're using Browserify, the easiest way to plug tempistry into your pipeline is via the included transform, tempistry/transform. You can then require your template files directly and have them automatically registered with tempistry.
browserify -t tempistry/transform main.js
var b = browserify().transform('tempistry/transform');
var tempistry = require('tempistry');
tempistry.on('pre-render', function(data) {
data.helpers = myViewHelpers;
});
var template = require('./things.jade');
var html = template({
name: 'Kellan'
});
Client-Side
Tempistry runs in the browser w/ browserify and acts as a registry to hook pre/post render logic into. This is useful for mixing in common view data such as formatting helpers. It works well when combined with the server side serialize() function, but you can register any function you want with it.
var tempistry = require('tempistry');
var template = tempistry.register(function() { });
tempistry.on('pre-render', function(data) {
data.name = 'asher';
});
tempistry.on('post-render', function(result) {
console.log(result.data.name);
console.log(result.html);
});
var html = template({
name: 'kellan'
});
License
This software is free to use under the Yahoo! Inc. BSD license.
See the LICENSE file for license text and copyright information.
Third-pary open source code used are listed in our package.json file.