-
-
Save hatched/1903725 to your computer and use it in GitHub Desktop.
Simple Handlebars view engine for Express
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
var express = require('express'), | |
app = express.createServer(); | |
app.configure(function () { | |
// Use our custom Handlebars-based view engine as the default. | |
app.register('.handlebars', require('./view')); | |
app.set('view engine', 'handlebars'); | |
// ... | |
}); | |
// ... |
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
var Handlebars = require('../support/handlebars/handlebars.js').Handlebars; | |
// Export a compile() method for Express. | |
exports.compile = function (source, options) { | |
var template = Handlebars.compile(source); | |
return function (options) { | |
return template(options, options.helpers); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment