Express, body rendering layout, but not head drawing

My problem is due to the jade layout file being displayed incorrectly. The body is rendered, but the header labels in the html release are empty. I tried to make the layout.jade file separately and it works fine.

Here is my layout.jade file

!!! 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 

And here is my index.jade file

 .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 

And here is the function in my express application that displays the index file.

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

Thank you in advance for any help you give me.

+7
source share
1 answer

In express 3, layouts have been removed in favor of template inheritance, as described here . Jade readme describes how this works, and another example here .

You need to replace div!= body with block body (or similar). Then at the top of index.jade you need to add extends layout . Finally, put the contents of index.jade under the block body (or another name you used in layout.jade ).

+18
source

All Articles