node package manager


Precompile templates with browserify, or simply compile templates if in node environment


compile ye underscore templates from doth external files in node.js (or browserify).

var kt = require('knights-templar');
var template = kt.make(__dirname+'/template.html');
var markup = template({ name: 'andy', age: 24 });

Compiles content from a file located at path into an underscore template function.

You can use precompiled templates by registering them with this method at the beginning of your node.js or browserify app. The format of precompiled_map should be an object where keys are the path to a template file (e.g. an html file) and values are either the content of the template or a compiled template function. For example:

var precomp = {
	// if its the template string, compilation will happen at run-time
	'/path/to/some/template.html': '<div> <%= variable %> </div>'

	// this way, everything is precompiled
	'/path/to/another/template.html': function(obj){
		// precompiled gobble-dee-gook

var knight = require("knights-templar");
var template = knight.make('/path/to/some/template.html'); // will use the one from precomp
template({variable: 'interpolate me!'});