hoganshare
v1.0.2
Published
A CoffeeScript utility to share Hogan pre-compiled templates across server-side and client-side.
Downloads
5
Readme
Hoganshare
A CoffeeScript utility to share Hogan pre-compiled templates across server-side and client-side.
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.
###Installation
npm install hoganshare
###Usage with Express
In this example I assign a route to the JS template generated by Hoganshare
hoganshare = require 'hoganshare'
this.get("/templates.js", function (req, res) {
res.contentType(".js");
res.send(hoganshare.getTemplates("/path/to/templates"));
});
All you will have to do is then include /templates.js
in your page to have your templates assigned to the window.templatess
object.
Directories will be converted in name-spaces. E.g. partials/sidebar.html
will be saved in `templates.partials.sidebar' as a function.
Enjoy!