https://github.com/socketstream/ss-hogan
Hogan template engine wrapper providing server-side compiled templates for SocketStream apps
https://github.com/socketstream/ss-hogan
Last synced: 4 months ago
JSON representation
Hogan template engine wrapper providing server-side compiled templates for SocketStream apps
- Host: GitHub
- URL: https://github.com/socketstream/ss-hogan
- Owner: socketstream
- Created: 2012-02-01T16:45:29.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2012-04-10T14:49:36.000Z (about 14 years ago)
- Last Synced: 2025-11-27T10:45:41.076Z (6 months ago)
- Language: JavaScript
- Homepage:
- Size: 97.7 KB
- Stars: 9
- Watchers: 5
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
Awesome Lists containing this project
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
The `ss-hogan` module is installed by default with new apps created by SocketStream 0.3. If you don't already have it installed, add `ss-hogan` to your application's `package.json` file and then add this line to app.js:
```javascript
ss.client.templateEngine.use(require('ss-hogan'));
```
Restart the server. From now on all templates will be pre-compiled and accessibale via the `ss.tmpl` object.
Note: Hogan uses a small [client-side VM](https://raw.github.com/twitter/hogan.js/master/lib/template.js) 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.html
Can be rendered in your browser with
```javascript
// assumes var ss = require('socketstream')
var html = ss.tmpl['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:
```javascript
ss.client.templateEngine.use(require('ss-hogan'), '/hogan-templates');
```