examples: merge the jade example into ejs

closes #3223
This commit is contained in:
Jamie Barton 2017-02-26 13:26:39 +00:00 committed by Douglas Christopher Wilson
parent eece3850bc
commit 57d3dfd9f8
8 changed files with 6 additions and 78 deletions

View File

@ -24,6 +24,10 @@ app.engine('.html', require('ejs').__express);
app.set('views', path.join(__dirname, 'views'));
// Path to our public directory
app.use(express.static(path.join(__dirname + 'public')));
// Without this you would need to
// supply the extension to res.render()
// ex: res.render('users.html').

View File

@ -2,12 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title> <%= title %> </title>
<style type="text/css">
body {
padding: 50px;
font: 13px Helvetica, Arial, sans-serif;
}
</style>
<title><%= title %></title>
<link rel="stylesheet" href="/stylesheets/style.css">
</head>
<body>

View File

@ -1,52 +0,0 @@
/**
* Module dependencies.
*/
var express = require('../../lib/express');
var path = require('path');
// Path to our public directory
var pub = path.join(__dirname, 'public');
// setup middleware
var app = express();
app.use(express.static(pub));
// Optional since express defaults to CWD/views
app.set('views', path.join(__dirname, 'views'));
// 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', 'tj@vision-media.ca')
, new User('ciaran', 'ciaranj@gmail.com')
, new User('aaron', 'aaron.heckmann+github@gmail.com')
];
app.get('/', function(req, res){
res.render('users', { users: users });
});
// change this to a better error handler in your code
// sending stacktrace to users in production is not good
app.use(function(err, req, res, next) {
res.send(err.stack);
});
/* istanbul ignore next */
if (!module.parent) {
app.listen(3000);
console.log('Express started on port 3000');
}

View File

@ -1,3 +0,0 @@
head
title Jade Example
link(rel="stylesheet", href="/stylesheets/style.css")

View File

@ -1,5 +0,0 @@
doctype html
html
include header
body
block content

View File

@ -1,8 +0,0 @@
extends ../layout
block content
h1 Users
#users
for user in users
include user

View File

@ -1,3 +0,0 @@
.user
h2= user.name
.email= user.email