Permalink
Browse files

Documentation that led me to this fix:

1) https://github.com/visionmedia/express/wiki/Migrating-from-2.x-to-3.x
"the concept of a "layout" (template engine specific now)"

2) http://www.devthought.com/code/use-jade-blocks-not-layouts/

Updated package.json versions for express and jade from 3.1.0, >= 0.0.1 to 3.2.4, 0.30.0 respectively.
Added extends layout and block content to about.jade and home.jade.
Referenced the block content from specific jade files in layout.jade as "div.container!= body" seemed to be generating the following error when requesting home:

ReferenceError: home.jade:23

body is not defined
    at eval (eval at <anonymous> (MySite/node_modules/jade/lib/jade.js:171:8), <anonymous>:238:64)
    at MySite/node_modules/jade/lib/jade.js:172:35
    at Object.exports.render (MySite/node_modules/jade/lib/jade.js:206:14)
    at View.exports.renderFile [as engine] (MySite/node_modules/jade/lib/jade.js:233:13)
    at View.render (MySite/node_modules/express/lib/view.js:75:8)
    at Function.app.render (MySite/node_modules/express/lib/application.js:506:10)
    at ServerResponse.res.render (MySite/node_modules/express/lib/response.js:756:7)
    at exports.home (MySite/routes/index.js:19:7)
    at callbacks (MySite/node_modules/express/lib/router/index.js:161:37)
    at param (MySite/node_modules/express/lib/router/index.js:135:11)
GET /home 500 22ms
  • Loading branch information...
1 parent 49bc583 commit 8ac368e69e97cd954850f93de557d2d9d6ff0004 @binarymist committed Jun 17, 2013
Showing with 17 additions and 11 deletions.
  1. +2 −2 package.json
  2. +6 −3 views/about.jade
  3. +6 −3 views/home.jade
  4. +3 −3 views/layout.jade
View
@@ -3,7 +3,7 @@
, "version": "0.0.1"
, "private": true
, "dependencies": {
- "express": "3.1.0"
- , "jade": ">= 0.0.1"
+ "express": "3.2.4",
+ "jade": "0.30.0",
}
}
View
@@ -1,3 +1,6 @@
-div.hero-unit
- h1= title
- p This is the #{title}
+extends layout
+
+block content
+ div.hero-unit
+ h1= title
+ p This is the #{title}
View
@@ -1,3 +1,6 @@
-div.hero-unit
- h1= title
- p Welcome to #{title}
+extends layout
+
+block content
+ div.hero-unit
+ h1= title
+ p Welcome to #{title}
View
@@ -1,4 +1,4 @@
-!!!
+doctype 5
html
include inc/header
@@ -21,7 +21,7 @@ html
li
a(href='#{key}') #{val}
- div.container!= body
- include inc/footer
+ block content
+ include inc/footer
include inc/scripts

0 comments on commit 8ac368e

Please sign in to comment.