Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[examples] Replace Jade with Pug #3183

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/expose-data-to-client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var express = require('../..');
var logger = require('morgan');
var app = express();

app.set('view engine', 'jade');
app.set('view engine', 'pug');
app.set('views', __dirname + '/views');

function User(name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ html
p The following was exposed to the client:
pre
script.
document.write(JSON.stringify(data, null, 2))
document.write(JSON.stringify(data, null, 2))
3 changes: 0 additions & 3 deletions examples/jade/views/header.jade

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
link(rel='stylesheet', href='/style.css')
h1= user.name
form(action='/user/#{user.id}?_method=put', method='post')
form(action='/user/' +user.id + '?_method=put', method='post')
label= 'Name: '
input(type='text', name='user[name]', value='#{user.name}')
input(type='text', name='user[name]', value=user.name)
input(type='submit', value='Update')

form(action='/user/#{user.id}/pet', method='post')
form(action='/user/' + user.id + '/pet', method='post')
label= 'Pet: '
input(type='text', name='pet[name]', placeholder='Name')
input(type='submit', value='Add')
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ p Click a user below to view their pets.
ul
each user in users
li
a(href='/user/#{user.id}')= user.name
a(href='/user/' + user.id)= user.name
Copy link
Contributor Author

@notrab notrab Jan 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Node 4+ would allow this to be written as

a(href=`/user/${user.id}`)= user.name

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
link(rel='stylesheet', href='/style.css')
h1= user.name + ' '
a(href='/user/#{user.id}/edit') edit
a(href='/user/' + user.id + '/edit') edit

if (hasMessages)
ul#messages
Expand All @@ -12,6 +12,6 @@ if (user.pets.length)
ul
each pet in user.pets
li
a(href='/pet/#{pet.id}')= pet.name
a(href='/pet/' + pet.id)= pet.name
else
p No pets!
4 changes: 2 additions & 2 deletions examples/mvc/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ var app = module.exports = express();

// settings

// set our default template engine to "jade"
// set our default template engine to "pug"
// which prevents the need for extensions
app.set('view engine', 'jade');
app.set('view engine', 'pug');

// set views for error and 404 pages
app.set('views', __dirname + '/views');
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions examples/jade/index.js → examples/pug/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ app.use(express.static(pub));

app.set('views', __dirname + '/views');

// Set our default template engine to "jade"
// Set our default template engine to "pug"
// which prevents the need for extensions
// (although you can still mix and match)
app.set('view engine', 'jade');
app.set('view engine', 'pug');

function User(name, email) {
this.name = name;
Expand Down
3 changes: 3 additions & 0 deletions examples/pug/views/header.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
head
title Pug Example
link(rel="stylesheet", href="/stylesheets/style.css")
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/route-separation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = app;

// Config

app.set('view engine', 'jade');
app.set('view engine', 'pug');
app.set('views', __dirname + '/views');

/* istanbul ignore next */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ block content
h1 Editing #{user.name}
#user
form(action="?_method=put", method="post")
p Name:
p Name:
input(type="text", value= user.name, name="user[name]")
p Email:
p Email:
input(type="text", value= user.email, name="user[email]")
p
p
input(type="submit", value="Save")
9 changes: 0 additions & 9 deletions examples/route-separation/views/users/index.jade

This file was deleted.

9 changes: 9 additions & 0 deletions examples/route-separation/views/users/index.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
extends ../layout

block content
h1 Users
#users
for user, i in users
li
a(href='/user/' + i)= user.name
a.edit(href='/user/' + i + '/edit') edit
4 changes: 2 additions & 2 deletions examples/search/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var db = redis.createClient();

var app = express();

app.set('view engine', 'jade');
app.set('view engine', 'pug');
app.set('views', __dirname);

// populate search
Expand Down Expand Up @@ -49,7 +49,7 @@ app.get('/search/:query?', function(req, res){
/**
* GET client javascript. Here we use sendFile()
* because serving __dirname with the static() middleware
* would also mean serving our server "index.js" and the "search.jade"
* would also mean serving our server "index.js" and the "search.pug"
* template.
*/

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/view-locals/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var User = require('./user');
var app = express();

app.set('views', __dirname);
app.set('view engine', 'jade');
app.set('view engine', 'pug');

// filter ferrets only

Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,9 @@ app.route = function route(path) {
*
* By default will `require()` the engine based on the
* file extension. For example if you try to render
* a "foo.jade" file Express will invoke the following internally:
* a "foo.pug" file Express will invoke the following internally:
*
* app.engine('jade', require('jade').__express);
* app.engine('pug', require('pug').__express);
*
* For engines that do not provide `.__express` out of the box,
* or if you wish to "map" a different extension to the template engine
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@
"devDependencies": {
"after": "0.8.2",
"body-parser": "1.16.0",
"connect-redis": "~2.4.1",
"cookie-parser": "~1.4.3",
"cookie-session": "~1.2.0",
"ejs": "2.5.5",
"express-session": "1.15.0",
"istanbul": "0.4.5",
Expand All @@ -66,11 +68,9 @@
"mocha": "3.2.0",
"morgan": "~1.7.0",
"multiparty": "4.1.3",
"pug": "^2.0.0-beta9",
"should": "11.1.2",
"supertest": "1.2.0",
"connect-redis": "~2.4.1",
"cookie-session": "~1.2.0",
"jade": "~1.11.0",
"vhost": "~3.0.2"
},
"engines": {
Expand Down