Speed up development with full-stack environments for every branch.

Learn More

Render jade with express [Node.js]

9416 Runs 55889 Views 22181 Copies
Saved

Saved

runnable 15

runnable
published 4 years ago

/**
 * Module dependencies.
 */

var express = require('express');

// Path to our public directory

var pub = __dirname;

// setup middleware

var app = express();
app.use(app.router);
app.use(express.static(pub));
app.use(express.errorHandler());

// Optional since express defaults to CWD/views

app.set('views', __dirname);

// Set our default template engine to "jade"
// which prevents the need for extensions
// (although you can still mix and match)
app.set('view engine', 'jade');

function User(name, email) {
  this.name = name;
  this.email = email;
}



// Dummy users
var users = [
    new User('tj', '[email protected]')
  , new User('ciaran', '[email protected]')
  , new User('aaron', '[email protected]')
];

app.get('/', function(req, res){
  res.render('index', { users: users });
});

app.listen(80);
console.log('Express app started on port %d', 80);
Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).