Skip to content

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

Notifications You must be signed in to change notification settings

tancredi/hoganshare

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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!

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published