Skip to content

Instantly share code, notes, and snippets.

@eunjae-lee
Created July 18, 2012 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eunjae-lee/3137460 to your computer and use it in GitHub Desktop.
Save eunjae-lee/3137460 to your computer and use it in GitHub Desktop.
hogan-express adapter
###
hogan-express.coffee
###
exports.init = (hogan, fs) ->
return (path, options, fn) ->
fs.readFile path, 'utf8', (err, str) ->
return fn(err) if err
result = hogan.compile(str).render(options)
fn null, result
###
app.coffee
###
express = require 'express'
adapter = require './hogan-express'
hogan = require 'hogan'
fs = require 'fs'
app = express()
app.configure () ->
app.set 'views', __dirname + '/views'
app.set 'view engine', '.html'
app.engine '.html', adapter.init(hogan, fs)
# ...
@eunjae-lee
Copy link
Author

hogan-express adapter

This gits indicates how to use hogan.js for express in nodeJS server application.
Since 3.x, express has removed app.register(). Instead, you should use app.engine() and its usage is a little different from before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment