简体   繁体   中英

Node.js - How to use jade partials with express.js (2.5.8)

I am posting this questions after reading this similar SO question

I have a node.js app running which uses Express 2.5.8 and Jade 0.26.0

I have a jade page that will consist of many widgets. On scouring the internet it seemed ideal to use partials to modularize these widgets.

So my jade main page called comp.jade is

!!! 5
html(lang='en')
head
  body
    h2.page-header REPORT FOR #{comp_name}
    .other_ds
      partial('partials/ln_profile') 

And my ln_profile.jade is

p.ln_profile
    strong  #{comp_ln_name}  
      br
      | #{comp_description}

On the server side my script looks like

res.render('comp',{comp_name: 'Some Company'}); // to pass data to comp.jade
res.partial( 'partials/ln_profile',{comp_ln_name: 'Test Company',comp_description:'Test Description'});  // to pass data to ln_profile.jade

But when I do this only ln_profile.jade gets rendered and the comp.jade is not getting rendered.

Where am I going wrong here ?

Partials is deprecated. You have to use Include statement instead of partials.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM