Switch branches/tags
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
98 lines (61 sloc) 2.73 KB


fs-hogan is a fork of Hogan.js, a fast mustache-compatible templating engine that supports template inheritance (supers), a feature that may make it into the official spec for mustache v2.0.0. The goal of fs-hogan is to take advantage of Hogan.js while also making rendering templates from the file system a breeze.


$ npm install fs-hogan



var hogan = require('fs-hogan');


  • cache: if true, fs-hogan will cache file templates after they are read from disk. [default: false]
  • templates: the path fs-hogan will look for templates in. [default: 'views']
  • extension: the file extension used for templates. [default: 'hjs']

In addition to these options, fs-hogan also supports the compilation options of Hogan.js.


hogan.set(option, value)

Sets option to value. To set multiple options at once, you can pass in an object that maps keys to options. Returns hogan so you can configure fs-hogan while requiring it.

hogan.renderFile(path, [context], [callback])

Asynchronously renders the template that exists at path with the context provided by context and then calls callback with 2 arguments: err and text.

When path is a relative path, templates will be used as the base path.


A working example of fs-hogan exists in the /examples directory.


fs-hogan works great with Express.

var express = require('express');
var hogan = require('fs-hogan');

var app = express();

app.configure(function() {
  app.set('views', __dirname + '/views');
  app.set('view engine', 'hjs');                                                
  hogan.set({ templates: app.get('views'), extension: app.get('view engine') });
  app.engine('hjs', hogan.renderFile);


Found a bug? Create an issue on GitHub.


For transparency and insight into the release cycle, releases will be numbered with the follow format:


And constructed with the following guidelines:

  • Breaking backwards compatibility bumps the major
  • New additions without breaking backwards compatibility bumps the minor
  • Bug fixes and misc changes bump the patch

For more information on semantic versioning, please visit


Copyright (c) 2012 Jake Harding
Licensed under the MIT License.