Socket
Socket
Sign inDemoInstall

hoganshare

Package Overview
Dependencies
4
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

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.


Version published
Weekly downloads
3
increased by200%
Maintainers
1
Install size
1.35 MB
Created
Weekly downloads
 

Readme

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

FAQs

Last updated on 30 Sep 2012

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc