开发者

How to embed content in jade

开发者 https://www.devze.com 2023-04-04 07:20 出处:网络
I\'m currently experimenting with jade template engine. I\'ve got the follow basic code in my layout.jade file:

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'.jad开发者_高级运维e 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
0

精彩评论

暂无评论...
验证码 换一张
取 消