Created
December 23, 2011 05:51
-
-
Save smebberson/1513308 to your computer and use it in GitHub Desktop.
Using mustache as an Express view engine
This file contains hidden or 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
// module depencies | |
var express = require('express'); | |
var app = express.createServer(); | |
// variables | |
var port = 3000; | |
// config | |
app.set('view engine', 'mustache'); | |
app.register(".mustache", require('stache')); | |
// routes | |
app.get('/', function (req, res) { | |
res.render('index', { | |
locals: { | |
title: 'Welcome' | |
} | |
}); | |
}); | |
//Run | |
app.listen(port); | |
console.log('Example running on port %s', port); |
This file contains hidden or 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
<!DOCTYPE HTML> | |
<html lang="en-us"> | |
<head> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> | |
<title>{{title}}</title> | |
</head> | |
<body> | |
<h1>Welcome</h1> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment