1

I have the following layout.jade:

!!!
html
  head
    title= title
    link(rel='stylesheet', href='/stylesheets/style.css')
  body!= body

In the body, I'd like to include the contents of another file, content.jade.

I'm trying something like this in app.js:

app.get('/test', function(req, res){
  res.render('layout', {
    layout: false,
    body: include content.jade
  });
});

but it gives SyntaxError: Unexpected identifier at 'content'. Is there a way to do this?

ario
  • 1,727
  • 4
  • 19
  • 28

1 Answers1

4

You have to render your content (body) file, not the layout. With the layout: true param (which is the default, I think) jade will automatically use layout.jade to render the "frame" of your page, and then feed your content in the body variable, passed to the layout ( see Expres doc ). so:

res.render('content');

should do the job.

mna
  • 22,989
  • 6
  • 46
  • 49