refactor ejs example
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by TJ Holowaychuk · committed by TJ Holowaychuk · parent a52b1f1 · Browse files · 11 files·+32 added−69 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
11 files+32 added−69 removed
- tests:+3 added−3 removed
- other:+29 added−66 removed
Provenance
- Commit
d653d23- Tree
5bb0724- Author
TJ Holowaychuk <tj@vision-media.ca>- Committer
TJ Holowaychuk <tj@vision-media.ca>- Parent
a52b1f1
11 files changed+32 added−69 removed
modified:examples/auth/views/head.ejs-4 removed
11 unmodified lines12 }13 .success {14 color: green;15 }16- footer {17- margin-top: 50px;18- color: gray;19- }16 </style>17 </head>18 <body>deleted:examples/ejs/views/footer/all.html-7 removed
1234567 <footer> <p> <%= title %> </p> </footer></body></html>deleted:examples/ejs/views/header/all.html-20 removed
1234567891011121314151617181920<!DOCTYPE HTML><html lang="en"><head> <meta charset="UTF-8"> <title> <%= title %> </title> <style type="text/css"> body { padding: 50px; font: 13px Helvetica, Arial, sans-serif; } .header { font-size: 4em; } footer { margin-top: 50px; color: gray; } </style></head><body>deleted:examples/ejs/views/header/emails.html-3 removed
123<% include all.html %>
<h1 class="header">Some email address</h1>deleted:examples/ejs/views/header/users.html-3 removed
123<% include all.html %>
<h1 class="header">Some users</h1>deleted:examples/ejs/views/emails.html-12 removed
123456789101112<% include header/emails.html %>
<h1>Emails</h1><ul id="emails"> <% users.forEach(function(user){ %> <li><%= user.email %> by <%= user.name %></li> <% }) %></ul>
<p><a href="/">back</a></p>
<% include footer/all.html %>added:examples/ejs/views/footer.html+2 added
12</body></html>added:examples/ejs/views/header.html+20 added
1234567891011121314151617181920<!DOCTYPE HTML><html lang="en"><head> <meta charset="UTF-8"> <title> <%= title %> </title> <style type="text/css"> body { padding: 50px; font: 13px Helvetica, Arial, sans-serif; } .header { font-size: 4em; } footer { margin-top: 50px; color: gray; } </style></head><body>modified:examples/ejs/views/users.html+3 added-5 removed
1-<% include header/users.html %>1+<% include header.html %>2 3 <h1>Users</h1>4 <ul id="users">5 <% users.forEach(function(user){ %>6- <li><%= user.name %> <%= user.email %></li>6+ <li><%= user.name %> <<%= user.email %>></li>7 <% }) %>8 </ul>9 10-<p><a href="/next">next</a></p> 11-12-<% include footer/all.html %>10+<% include footer.html %>modified:examples/ejs/index.js+4 added-12 removed
29 unmodified lines30 app.set('view engine', 'html');31 32 // Dummy users33 var users = [34- { name: 'tobi', email: 'tobi@learnboost.com' }35- , { name: 'loki', email: 'loki@learnboost.com' }36- , { name: 'jane', email: 'jane@learnboost.com' }34+ { name: 'tobi', email: 'tobi@learnboost.com' },35+ { name: 'loki', email: 'loki@learnboost.com' },36+ { name: 'jane', email: 'jane@learnboost.com' }37 ];38 39 app.get('/', function(req, res){40 res.render('users', {41- users: users,42- title: "EJS example",43- header: "Some users"44- });45-});46-47-app.get('/next', function(req, res){48- res.render('emails', {41 users: users,42 title: "EJS example",51- header: "Some email address"43+ header: "Some users"44 });45 });46 47 if (!module.parent) {3 unmodified linesmodified:test/acceptance/ejs.js+3 added-3 removed
8 unmodified lines9 .get('/')10 .end(function(err, res){11 res.should.have.status(200);12 res.should.have.header('Content-Type', 'text/html; charset=utf-8');13- res.text.should.include('<li>tobi tobi@learnboost.com</li>');14- res.text.should.include('<li>loki loki@learnboost.com</li>');15- res.text.should.include('<li>jane jane@learnboost.com</li>');13+ res.text.should.include('<li>tobi <tobi@learnboost.com></li>');14+ res.text.should.include('<li>loki <loki@learnboost.com></li>');15+ res.text.should.include('<li>jane <jane@learnboost.com></li>');16 done();17 });18 })19 })1 unmodified line