Hogan template engine wrapper providing server-side compiled templates for SocketStream apps
JavaScript
Pull request Compare This branch is 1 commit ahead of socketstream:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
HISTORY.md
README.md
engine.js
handlebars.runtime.js
package.json

README.md

Handlebars Template Engine wrapper for SocketStream 0.3

http://handlebarsjs.com/

Use pre-compiled Handlebars client-side templates in your app.

Installation

Add ss-handlebars to your application's package.json file and then add this line to app.js:

ss.client.templateEngine.use(require('ss-handlebars'));

Restart the server. From now on all templates will be pre-compiled and accessibale via the ss.tmpl object.

Note: Handlebars uses a small client-side runtime which renders the pre-compiled templates. This file is included and automatically sent to the client.

Usage

E.g. a template placed in

/client/templates/offers/latest.hds

Can be rendered in your browser with

// assumes var ss = require('socketstream')
var html = ss.tmpl['offers-latest']({name: 'Special Offers'})

Options

When experimenting with Handlebars, or converting an app from one template type to another, you may find it advantageous to use multiple template engines and confine use of Handlebars to a sub-directory of /client/templates.

Directory names can be passed to the second argument as so:

ss.client.templateEngine.use(require('ss-handlebars'), '/hds-templates');