diff --git a/examples/mvc/controllers/pet/index.js b/examples/mvc/controllers/pet/index.js index 0702d289ec..c183e51c9e 100644 --- a/examples/mvc/controllers/pet/index.js +++ b/examples/mvc/controllers/pet/index.js @@ -4,8 +4,6 @@ var db = require('../../db'); -exports.engine = 'jade'; - exports.before = function(req, res, next){ var pet = db.pets[req.params.pet_id]; if (!pet) return next(new Error('Pet not found')); diff --git a/examples/mvc/controllers/user/views/edit.html b/examples/mvc/controllers/user/views/edit.html deleted file mode 100644 index f5b9ae9b5c..0000000000 --- a/examples/mvc/controllers/user/views/edit.html +++ /dev/null @@ -1,12 +0,0 @@ - -

<%= user.name %>

-
- - - -
- -
- - -
\ No newline at end of file diff --git a/examples/mvc/controllers/user/views/edit.jade b/examples/mvc/controllers/user/views/edit.jade new file mode 100644 index 0000000000..ab9cdbeecc --- /dev/null +++ b/examples/mvc/controllers/user/views/edit.jade @@ -0,0 +1,12 @@ +link(rel='stylesheet', href='/style.css') +h1= user.name +form(action='/user/#{user.id}', method='post') + input(type='hidden', name='_method', value='put') + label= 'Name: ' + input(type='text', name='user[name]', value='#{user.name}') + input(type='submit', value='Update') + +form(action='/user/#{user.id}/pet', method='post') + label= 'Pet: ' + input(type='text', name='pet[name]', placeholder='Name') + input(type='submit', value='Add') diff --git a/examples/mvc/controllers/user/views/list.html b/examples/mvc/controllers/user/views/list.html deleted file mode 100644 index 736025f06f..0000000000 --- a/examples/mvc/controllers/user/views/list.html +++ /dev/null @@ -1,8 +0,0 @@ - -

Users

-

Click a user below to view their pets.

- \ No newline at end of file diff --git a/examples/mvc/controllers/user/views/list.jade b/examples/mvc/controllers/user/views/list.jade new file mode 100644 index 0000000000..af8933cfe0 --- /dev/null +++ b/examples/mvc/controllers/user/views/list.jade @@ -0,0 +1,7 @@ +link(rel='stylesheet', href='/style.css') +h1 Users +p Click a user below to view their pets. +ul + each user in users + li + a(href='/user/#{user.id}')= user.name diff --git a/examples/mvc/controllers/user/views/show.html b/examples/mvc/controllers/user/views/show.html deleted file mode 100644 index 814a11a8d8..0000000000 --- a/examples/mvc/controllers/user/views/show.html +++ /dev/null @@ -1,21 +0,0 @@ - -

<%= user.name %> edit

- -<% if (hasMessages) { %> - -<% } %> - -<% if (user.pets.length) { %> -

View <%= user.name %>s pets:

- -<% } else { %> -

No pets!

-<% } %> \ No newline at end of file diff --git a/examples/mvc/controllers/user/views/show.jade b/examples/mvc/controllers/user/views/show.jade new file mode 100644 index 0000000000..267d3ef7e4 --- /dev/null +++ b/examples/mvc/controllers/user/views/show.jade @@ -0,0 +1,17 @@ +link(rel='stylesheet', href='/style.css') +h1= user.name + ' ' + a(href='/user/#{user.id}/edit') edit + +if (hasMessages) + ul#messages + each msg in messages + li= msg + +if (user.pets.length) + p View #{user.name}'s pets: + ul + each pet in user.pets + li + a(href='/pet/#{pet.id}')= pet.name +else + p No pets! diff --git a/examples/mvc/index.js b/examples/mvc/index.js index 297344b5a2..f228a375e6 100644 --- a/examples/mvc/index.js +++ b/examples/mvc/index.js @@ -13,11 +13,9 @@ var app = module.exports = express(); // settings -// map .renderFile to ".html" files -app.engine('html', require('ejs').renderFile); - -// make ".html" the default -app.set('view engine', 'html'); +// set our default template engine to "jade" +// which prevents the need for extensions +app.set('view engine', 'jade'); // set views for error and 404 pages app.set('views', __dirname + '/views'); diff --git a/examples/mvc/views/404.html b/examples/mvc/views/404.html deleted file mode 100644 index 5710154e15..0000000000 --- a/examples/mvc/views/404.html +++ /dev/null @@ -1,3 +0,0 @@ - -

404: Not Found

-

Sorry we can't find <%= url %>

\ No newline at end of file diff --git a/examples/mvc/views/404.jade b/examples/mvc/views/404.jade new file mode 100644 index 0000000000..110c471f1b --- /dev/null +++ b/examples/mvc/views/404.jade @@ -0,0 +1,3 @@ +link(rel='stylesheet', href='/style.css') +h1 404: Not Found +p Sorry we can't find #{url} diff --git a/examples/mvc/views/5xx.html b/examples/mvc/views/5xx.html deleted file mode 100644 index 2d810558dd..0000000000 --- a/examples/mvc/views/5xx.html +++ /dev/null @@ -1,3 +0,0 @@ - -

500: Internal Server Error

-

Looks like something blew up!

\ No newline at end of file diff --git a/examples/mvc/views/5xx.jade b/examples/mvc/views/5xx.jade new file mode 100644 index 0000000000..3508b7c0e2 --- /dev/null +++ b/examples/mvc/views/5xx.jade @@ -0,0 +1,3 @@ +link(rel='stylesheet', href='/style.css') +h1 500: Internal Server Error +p Looks like something blew up!