Skip to content

Instantly share code, notes, and snippets.

@lvivier
Last active August 29, 2015 14:15
Show Gist options
  • Save lvivier/d297a0e3e3890635f180 to your computer and use it in GitHub Desktop.
Save lvivier/d297a0e3e3890635f180 to your computer and use it in GitHub Desktop.
Using EJS with express instead of jade
<!DOCTYPE html>
<h1><%= title %></h1>
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'})
}
{
"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