hoganshare

1.0.2 • Public • Published

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'
 
hoganshare = new HoganShare("/path/to/templates");
 
this.get("/templates.js", function (req, res) {
    res.contentType(".js");
    res.send(hoganshare.getTemplates());
});

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'].

Enjoy!

Readme

Keywords

none

Package Sidebar

Install

npm i hoganshare

Weekly Downloads

1

Version

1.0.2

License

MIT

Last publish

Collaborators

  • tancredi