Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

ss-hogan

Hogan template engine wrapper providing server-side compiled templates for SocketStream apps

readme

Hogan Template Engine wrapper for SocketStream 0.3

http://twitter.github.com/hogan.js/

Use pre-compiled Hogan (Mustache-compatible) client-side templates in your app to benefit from increased performance and a smaller client-side library download.

Installation

Note: ss-hogan is installed by default with new apps created by SocketStream 0.3 alpha2 onwards.

First download template.js from https://raw.github.com/twitter/hogan.js/master/lib/template.js and add this to your /client/code/lib folder. This is the Hogan VM which renders pre-compiled templates. It is smaller in size than the all-inclusive hogan.js file which includes the compiler and should not be sent to the client.

Secondly, add ss-hogan to your application's package.json file and then add this line to app.js:

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

Restart the server. From now on all templates will be pre-compiled and attached to the HT window/global variable.

Usage

E.g. a template placed in

/client/templates/offers/latest.html

Can be rendered in your browser with

html = HT['offers-latest'].render({name: 'Special Offers'})

Options

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

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

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

To specify another global/window variable instead of HT set the 'namespace' option in the config as so:

ss.client.templateEngine.use(require('ss-hogan'), '/', {namespace: 'MyVar'});

changelog

0.1.3 / 2012-04-10

  • New API for SocketStream 0.3 beta2
  • Now includes client code (Hogan VM) for client
  • Improved error reporting in console
  • Reset repo to remove rubbish

0.1.2 / 2012-03-17

  • Templates are now appended to ss.tmpl instead of global variables (e.g. HT)
  • Tip: You may put window.HT = ss.tmpl into entry.js to avoid changing your code
  • Reduced amount of code output for apps with many templates

0.1.1 / 2012-03-17

  • Upgraded hogan to 2.0.0

0.1.0 / 2012-01-14

  • Initial commit