node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »



A CoffeeScript utility to share Hogan pre-compiled templates across server-side and client-side.

Build Status

Given a directory name and an extension (optional - set as .html by default) Hoganshare will return a javascript string that declares all found templates as compiled function, saving them under window.templates namespace.


npm install hoganshare

Usage with Express

In this example I assign a route to the JS template generated by Hoganshare

HoganShare = require 'hoganshare'
hoganshare = new HoganShare("/path/to/templates");
this.get("/templates.js", function (req, res) {

All you will have to do then is including /templates.js in your page to have your templates assigned to the window.templatess object.

Path and filename will used as index in the templates array. E.g. partials/sidebar.html will be saved as a function under templates['templates/partials/sidebar'].