Skip to content

Commit 3371d29

Browse files
author
codingChewie
committed
Express’s Response.render Method
1 parent ad55a71 commit 3371d29

File tree

5 files changed

+35
-5
lines changed

5 files changed

+35
-5
lines changed

app.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const express = require('express')
2+
const eyes = require('eyespect')
23

34
const app = express()
45

@@ -8,8 +9,13 @@ app.get('/', (req, res) => {
89
res.render('index')
910
})
1011

11-
app.get('/hello', (req, res) => {
12-
res.send('<h1>Hello Foobar</h1>')
12+
app.get('/cards', (req, res) => {
13+
eyes.inspect(res.locals, 'res.locals')
14+
15+
res.render('card', {
16+
prompt: `Who is buried in Grant's tomb?`,
17+
hint: `Think about whose tomb it is?`,
18+
})
1319
})
1420

1521
app.listen(3000, () => console.log('The app is running on port 3000'))

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"eslint-plugin-node": "^10.0.0",
3434
"eslint-plugin-prettier": "^3.1.1",
3535
"eslint-plugin-react": "^7.14.3",
36+
"eyespect": "^0.1.10",
3637
"nodemon": "^1.19.2",
3738
"prettier": "^1.18.2"
3839
},

views/card.pug

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
doctype html
2+
html(lang="en")
3+
head
4+
title Flash Cards
5+
body
6+
header
7+
h1 Flash Cards
8+
section#content
9+
h2= prompt
10+
p
11+
i Hint: #{hint}
12+
footer
13+
p An app to help you stufy

views/index.pug

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
doctype html
22
html(lang="en")
33
head
4-
title Landing Page
4+
title Flash Cards
55
body
6-
h1 The future of something magical
7-
p Something lipsum
6+
header
7+
h1 Flash Cards
8+
section#content
9+
h2 Welcome, student
10+
footer
11+
p An app to help you stufy

0 commit comments

Comments
 (0)