Last active
August 29, 2015 14:15
-
-
Save lvivier/d297a0e3e3890635f180 to your computer and use it in GitHub Desktop.
Using EJS with express instead of jade
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
<!DOCTYPE html> | |
<h1><%= title %></h1> |
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') | |
var PORT = 1234 | |
express() | |
.set('views', __dirname) | |
.set('view engine', 'ejs') | |
.get('/', home) | |
.listen(PORT, onlisten) | |
function onlisten(){ | |
console.log('open http://localhost:%d/', PORT) | |
} | |
function home (req, res) { | |
// resolves to __dirname+/home.ejs | |
res.render('home', {title:'hello world'}) | |
} |
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
{ | |
"dependencies": { | |
"ejs": "^2.2.4", | |
"express": "^4.11.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment