1.0.2 • Published 12 years ago

hoganshare v1.0.2

Weekly downloads
1
License
-
Repository
-
Last release
12 years ago

Hoganshare

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.

###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!

1.0.2

12 years ago

1.0.1

12 years ago

1.0.0

12 years ago