Skip to content

Instantly share code, notes, and snippets.

@yyfrankyy
Created September 19, 2010 14:20
Show Gist options
  • Save yyfrankyy/586806 to your computer and use it in GitHub Desktop.
Save yyfrankyy/586806 to your computer and use it in GitHub Desktop.
<h1>{{title}}</h1>
//change express render engine to mustache
var express = require('express'),
app = express.createServer(),
port = 1234,
mustache = require('mustache');
app.register('.html', {
render: function(str, options){
return mustache.to_html(str, options.locals);
}
});
app.set('view engine', 'mustache');
app.set('view options', {
layout: false
});
app.get('/', function(req, res){
res.render('index.html', {
locals: {
title: 'f2e.us'
}
});
});
app.listen(port);
[~ dev]$ curl http://localhost:1234
<h1>f2e.us</h1>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment