Created
July 18, 2012 16:59
-
-
Save eunjae-lee/3137460 to your computer and use it in GitHub Desktop.
hogan-express adapter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
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) | |
# ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.