Hogan.js NPM package for express 3.x (hjs)
JavaScript
Switch branches/tags
Nothing to show
Latest commit ecc0d9c Mar 8, 2017 @nullfirm nullfirm Merge pull request #13 from alloctag/master
partials support compilation options
Permalink
Failed to load latest commit information.
bin update check Sep 11, 2013
lib partials support compilation options Oct 10, 2015
LICENSE add Apache Licence Jun 13, 2012
README.md Support for app-wide partials + doc updates May 27, 2014
index.js add Apache Licence Jun 13, 2012
package.json rename Sep 11, 2013

README.md

hjs

Hogan.js NPM package for express 3.x

Installation

$ npm install -g express@3.0  hjs

Quick Start

Install Express :

$ npm install -g express@3.0

Create express app :

$ express -H /tmp/testapp
$ cd /tmp/testapp/
& npm install

Manual Start

Install Express :

$ npm install -g express@3.0

Create express app :

$ express /tmp/testapp
$ cd /tmp/testapp/

Edit package.json :

$ vi package.json
"dependencies": {
    "express": "3.0.0",
    "hjs": "*"
}
$ npm install

Edit app.js :

app.set('view engine', 'hjs');

Make views/index.hjs :

<html>
<head>
    <title>{{ title }}</title>
</head>
<body>
    <p>{{ title }}</p>
</body>
</html>

Start server :

$ node app

Partials

index.hjs

<html>
<head>
    <title>{{ title }}</title>
</head>
<body>
    <p>{{ title }}</p>
    {{> footer }}
</body>
</html>

footer.hjs

<div>My awesome footer</div>

To use a partial once:

res.render('index', {
    title: 'My Test App',
    partials: {footer: 'footer'}
});

To include a partial on every page:

app.set('partials', {footer: 'footer'});

More Information

express is Fast, unopinionated, minimalist web framework for node.

Hogan.js is a compiler for the Mustache templating language. For information on Mustache, see the manpage and the spec.