Express,jade布局文件渲染体但不渲染头

Ken*_*lin 7 node.js express pug

我的问题是我的玉器布局文件无法正确呈现.渲染了正文,但生成的html中的head标记为空.我试图分别渲染layout.jade文件,它完美地工作.

这是我的layout.jade文件

!!!
html
    head
        title= title
        link(rel='stylesheet', href='stylesheets/style.css')
        script(type='text/javascript', src='javascripts/jquery-1.7.2.js')
        link(rel='stylesheet', href='stylesheets/pictogram-button.css')
body
    header(style='padding-bottom:50px;')
        include partials/header
    section(style='min-height:600px;') 
        div!= body
    footer.footer
        include partials/footer
Run Code Online (Sandbox Code Playgroud)

这是我的index.jade文件

.line_h100t
.column_wrap800
    .round_box1_w800
        .list_fl10
            ul.line_h40
                li(style='margin-left:20px;')
                    ul
                        li
                            img(src='/images/icon/whiteWithoutCircle/check.png')
                            img(src='/images/login/loginTxt.png')
                    ul.line_h40t
                        li(style='margin-left:50px;')
                            p ???? ???? ??
                            p Oopa Roopa ????? ??? ???!
                li(style='border-left:1px solid #999; padding:0 0 0 20px;')
                    ul
                        li
                            span.text_yellow ID
                    ul
                        li
                            input.login_input(type='text')
                    ul.line_h35t
                        li
                            span.text_yellow PASSWORD
                    ul
                        li
                            input.login_input(type='password')
                li
                    ul.line_h10t
                        a.button-bevel.transparency(href='#')
                            .line_h35
                                span.lock
                                p(style='width:100px;') LOGIN
Run Code Online (Sandbox Code Playgroud)

这是我的快递应用程序中的函数,它呈现索引文件.

    adminLogin : function (req,res) {
    res.render( 'index', {
        title: 'Admin Login',
        pageCategory: 'Admin Login',
        pageName : 'index'
    });
},
Run Code Online (Sandbox Code Playgroud)

提前感谢你给我的任何帮助.

Dav*_*don 18

在快递3,布局有利于模板继承被拆除作为解释在这里.玉自述介绍如何工作的,以及附加的例子是在这里.

您将需要更换div!= bodyblock body(或类似).然后在顶部index.jade,你会想要添加extends layout.最后把内容index.jade放在a block body(或你用过的任何名字layout.jade)下面.