How can I extend jade layout from a view/parent/child structure?

拈花ヽ惹草 提交于 2019-12-01 07:14:09

问题


I have my Views structured like this

I wanted to extend the layout.jade to all jades under my user folder. Doing extends ../layout in the files under user folder doesn't work. There are no much writing about extending layouts that discuss about this.

Does Express allows this kind of extends?


回答1:


extends ../layout should work fine. Here is how I structure my views. What happens when you try to render the child template? Are you using blocks like I am, or includes?

// ls
+views
  +children
    -child.jade
  -layout.jade
  -sister.jade
-app.js

// layout.jade
!!!
html
  head
    script
      console.log('hi ho');
    block head
  body
    #wrapper
      block content

// sister.jade
extends layout
block append head
  style
    h1{ text-align: center}
block append content
  h1 Hello World

// children/child.jade
extends ../layout
block append content
  h1 Hello World


来源:https://stackoverflow.com/questions/18058055/how-can-i-extend-jade-layout-from-a-view-parent-child-structure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!