Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use multiple blocks from different files?

I have a layout.jade that looks like this:

html
  body
    block content
    block footer

My content.jade looks like that:

extends layout

block content
    #Content Welcome

My footer.jade looks like that:

extends layout

block footer
    #Footer Impressum

Now, when I run my app like that:

app.get('/', function(req, res) {
    res.render('layout');
});

I do not see neither the content nor the footer.

When I run:

app.get('/', function(req, res) {
    res.render('content');
});

Then I see the content.

When I run:

app.get('/', function(req, res) {
    res.render('footer');
});

Then I see the footer.

How can I see both, content and footer?

like image 875
Amberlamps Avatar asked Aug 20 '12 23:08

Amberlamps


1 Answers

You probably want something like this:

layout.jade

html
  body
    block content
    include footer

pagename.jade

extends layout

block content
  h1 My Content

footer.jade

p.footer Here is my footer

Then run res.render('pagename');.

Unless you want to have specific stuff in your footer per page, there's no point in making it a block.

like image 116
Michelle Tilley Avatar answered Sep 27 '22 21:09

Michelle Tilley