I am trying to use express and render a layout.jade my directory tree is pretty standard.
├── apps
│ └── fridge_face
│ ├── routes.coffee
│ └── views
| └── index.jade
├── server.js
└── views
├── layout.jade
└── stylesheets
└── style.styl
In my routes.coffee when I render index.jade everything words fine, but layout is not rendered. I have tried moving layout into apps/fridge_face/views/ but that was not successful.
I have done no layout configuration.
Here is my
layout.jade
doctype 5
html
head
title 'What is up'
link(rel='stylesheet', href='/stylesheets/style.css')
body
!= body
routes.coffee
routes = (app) ->
app.get '/', (req, res) ->
Word.once 'wordsFetched', (params) ->
res.render "#{__dirname}/views/index",
layout: true
words: params.map (word) -> word.word
Word.getWords()
module.exports = routes
server.js config
app.configure(function(){
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express['static'](__dirname + '/public'));
});
As you can see nothing that could or would make the layout not render… what am I doing wrong how do I get express to find my layout
Edit
I know I am making this question super long but adding some developments. First
When I remove the != from the layouts in both directories, nothing changes. My view is still rendered layout free.
When I add
app.set('view options', {
layout: false
});
and then explicitly render my layout in my view with either
layout: "#{__dirname}/views/layout"
# OR
layout: "layout"
# OR
layout: true
Nothing happens and the view is rendered layout free…
You are using outdated code with the new express version. Please see http://github.com/visionmedia/jade for the new usage of templating system.