Skip to content

Commit

Permalink
examples: replace jade with ejs in view-locals
Browse files Browse the repository at this point in the history
closes #3240
  • Loading branch information
notrab authored and dougwilson committed Mar 10, 2017
1 parent 64dd446 commit f44368f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
11 changes: 6 additions & 5 deletions examples/view-locals/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
*/

var express = require('../..');
var path = require('path');
var User = require('./user');
var app = express();

app.set('views', __dirname);
app.set('view engine', 'jade');
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');

// filter ferrets only

Expand All @@ -25,7 +26,7 @@ app.get('/', function(req, res, next){
if (err) return next(err);
User.all(function(err, users){
if (err) return next(err);
res.render('user', {
res.render('index', {
title: 'Users',
count: count,
users: users.filter(ferrets)
Expand Down Expand Up @@ -59,7 +60,7 @@ function users(req, res, next) {
}

app.get('/middleware', count, users, function(req, res, next){
res.render('user', {
res.render('index', {
title: 'Users',
count: req.count,
users: req.users.filter(ferrets)
Expand Down Expand Up @@ -101,7 +102,7 @@ app.get('/middleware-locals', count2, users2, function(req, res, next){
// to pass to res.render(). If we have
// several routes related to users this
// can be a great productivity booster
res.render('user', { title: 'Users' });
res.render('index', { title: 'Users' });
});

// keep in mind that middleware may be placed anywhere
Expand Down
12 changes: 0 additions & 12 deletions examples/view-locals/layout.jade

This file was deleted.

8 changes: 0 additions & 8 deletions examples/view-locals/user.jade

This file was deleted.

19 changes: 19 additions & 0 deletions examples/view-locals/views/index.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title><%= title %></title>
<style media="screen">
body {
padding: 50px;
font: 16px Helvetica, Arial;
}
</style>
</head>
<body>
<h2><%= title %></h2>
<% users.forEach(function(user) { %>
<li><strong><%= user.name %></strong> is a <% user.age %> year old <%= user.species %></li>
<% }); %>
</body>
</html>

0 comments on commit f44368f

Please sign in to comment.