Skip to content
Myr

examples: replace jade with hbs in mvc example

Before adoption: this commit came in with the history the project adopted, so no landing records it.

fixes #3181 closes #3185 closes #3243 closes #3245 closes #3249

authored by Jamie Barton · committed by Douglas Christopher Wilson · parent 8acaa9a · Browse files · 13 files+100 added−47 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

13 files+100 added−47 removed

  • other:+100 added−47 removed

13 files+100 added−47 removed

added:examples/mvc/controllers/user/views/edit.hbs+25 added
1<!DOCTYPE html>2<html>3<head>4 <link rel="stylesheet" href="/style.css">5 <title>Edit {{user.name}}</title>6</head>7<body>8 <h1>{{user.name}}</h1>9 <form action="/user/{{user.id}}?_method=put" method="post">10 <label for="user[name]">Name:11 <input type="text" name="user[name]" value="{{user.name}}">12 </label>1314 <input type="submit" name="submit" value="Update">15 </form>1617 <form action="/user/{{user.id}}/pet" method="post">18 <label for="pet[name]">Pet:19 <input type="text" name="pet[name]" placeholder="Pet Name">20 </label>2122 <input type="submit" name="submit" value="Add">23 </form>24</body>25</html>
deleted:examples/mvc/controllers/user/views/edit.jade-11 removed
1link(rel='stylesheet', href='/style.css')2h1= user.name3form(action='/user/#{user.id}?_method=put', method='post')4 label= 'Name: '5 input(type='text', name='user[name]', value='#{user.name}')6 input(type='submit', value='Update')78form(action='/user/#{user.id}/pet', method='post')9 label= 'Pet: '10 input(type='text', name='pet[name]', placeholder='Name')11 input(type='submit', value='Add')
added:examples/mvc/controllers/user/views/list.hbs+16 added
1<!DOCTYPE html>2<html>3<head>4 <link rel="stylesheet" href="/style.css">5 <title>Users</title>6</head>7<body>8 <h1>Users</h1>9 <p>Click a user below to view their pets.</p>10 <ul>11 {{#each users}}12 <li><a href="/user/{{id}}">{{name}}</a></li>13 {{/each}}14 </ul>15</body>16</html>
deleted:examples/mvc/controllers/user/views/list.jade-7 removed
1link(rel='stylesheet', href='/style.css')2h1 Users3p Click a user below to view their pets.4ul5 each user in users6 li7 a(href='/user/#{user.id}')= user.name
added:examples/mvc/controllers/user/views/show.hbs+29 added
1<!DOCTYPE html>2<html>3<head>4 <link rel="stylesheet" href="/style.css">5 <title>{{user.name}}</title>6</head>7<body>8<h1>{{user.name}} <a href="/user/{{user.id}}/edit">edit</a></h1>910{{#if hasMessages}}11 <ul>12 {{#each messages}}13 <li>{{this}}</li>14 {{/each}}15 </ul>16{{/if}}1718{{#if user.pets.length}}19 <p>View {{user.name}}'s pets:</p>20 <ul>21 {{#each user.pets}}22 <li><a href="/pet/{{id}}">{{name}}</a></li>23 {{/each}}24 </ul>25{{else}}26 <p>No pets!</p>27{{/if}}28</body>29</html>
deleted:examples/mvc/controllers/user/views/show.jade-17 removed
1link(rel='stylesheet', href='/style.css')2h1= user.name + ' '3 a(href='/user/#{user.id}/edit') edit45if (hasMessages)6 ul#messages7 each msg in messages8 li= msg910if (user.pets.length)11 p View #{user.name}'s pets:12 ul13 each pet in user.pets14 li15 a(href='/pet/#{pet.id}')= pet.name16else17 p No pets!
modified:examples/mvc/controllers/user/index.js+2 added
added:examples/mvc/views/404.ejs+12 added
1<!DOCTYPE html>2<html>3 <head>4 <meta charset="utf-8">5 <title>Not Found</title>6 <link rel="stylesheet" href="/style.css">7 </head>8 <body>9 <h1>404: Not Found</h1>10 <p>Sorry we can't find <%= url %></p>11 </body>12</html>
deleted:examples/mvc/views/404.jade-3 removed
1link(rel='stylesheet', href='/style.css')2h1 404: Not Found3p Sorry we can't find #{url}
added:examples/mvc/views/5xx.ejs+12 added
1<!DOCTYPE html>2<html>3 <head>4 <meta charset="utf-8">5 <title>Internal Server Error</title>6 <link rel="stylesheet" href="/style.css">7 </head>8 <body>9 <h1>500: Internal Server Error</h1>10 <p>Looks like something blew up!</p>11 </body>12</html>
deleted:examples/mvc/views/5xx.jade-3 removed
1link(rel='stylesheet', href='/style.css')2h1 500: Internal Server Error3p Looks like something blew up!
modified:examples/mvc/index.js+3 added-5 removed
9 unmodified lines
10var methodOverride = require('method-override');1112var app = module.exports = express();1314// settings14// set our default template engine to "ejs"15// which prevents the need for using file extensions16app.set('view engine', 'ejs');1716// set our default template engine to "jade"17// which prevents the need for extensions18app.set('view engine', 'jade');1918// set views for error and 404 pages19app.set('views', path.join(__dirname, 'views'));2021// define a custom res.message() method
73 unmodified lines
modified:package.json+1 added-1 removed
60 unmodified lines
61 "body-parser": "1.17.1",62 "cookie-parser": "~1.4.3",63 "ejs": "2.5.6",64 "express-session": "1.15.1",65 "hbs": "4.0.1",66 "istanbul": "0.4.5",67 "marked": "0.3.6",68 "method-override": "2.3.7",69 "mocha": "3.2.0",
3 unmodified lines
73 "should": "11.2.1",74 "supertest": "1.2.0",75 "connect-redis": "~2.4.1",76 "cookie-session": "~1.2.0",76 "jade": "~1.11.0",77 "vhost": "~3.0.2"78 },79 "engines": {80 "node": ">= 0.10.0"
15 unmodified lines