I'm currently experimenting with jade template engine. I've got the follow basic code in my layout.jade file:

!!! 5
html
  head
    title= title
    link(rel='stylesheet', href='/stylesheets/style.css')
  body!= body
    header != partial('partials/head')  
    'dependant page content to go here'
    footer != partial('partials/foot')  

I'd like every page to follow this same structure (for now). However I would like the content to change, and the content should be depended on what is inside the 'pagename'.jade files e.g. index.jade:

section#page-content
  h1= title
  p Welcome to #{title}

What i'm trying to say is, upon a new page loading.. the content tag in layout should somehow be replaced by the appropriate tag of the page being loaded.

有帮助吗?

解决方案

I think you're looking for:

  body
    header
      p my header
    section!= body
    footer
      p my footer

In this case, section!= body is replaced by whatever is in the 'pagename'.jade files.

其他提示

use blocks

in layout.jade:

body
  block some-block
    p Blah

in test.jade

extends layaout
block some-block
  p What
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top