🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

hoganshare

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hoganshare

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

latest
npmnpm
Version
1.0.2
Version published
Weekly downloads
1
-75%
Maintainers
1
Weekly downloads
 
Created
Source

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!

Keywords

shared

FAQs

Package last updated on 30 Sep 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts