Passing Options to Partials Using Jade

62 views
Skip to first unread message

Nick Steffens

unread,
Oct 31, 2012, 12:53:33 PM10/31/12
to doc...@googlegroups.com
Hello I am having some difficulty with Jade Partials passing it options:

in document:

    cta: ['Headline', 'copy' 'url']

in layout:

     div #{partial('cta.html.jade', cta_path: document.cta[2])}

in partials/cta.html.jade:

     a(href="#{cta_path}", target="_blank")


Not sure if I am using this correctly, but the partial without option(s) works great but I would like to add dynamic content to my partial. Trying to base it off of: http://www.hacksparrow.com/express-js-jade-partials-how-to-use-them.html. And also mimic the eco model of partials with options.

Rob Jensen

unread,
Dec 9, 2012, 3:58:25 AM12/9/12
to doc...@googlegroups.com
Right. So you got the partials folder, also using extension naming convention.. good. You don't need it for the partial tho, but it's still wrong. Why? You will need unescaped code, and pass it a JSON formatted data object, both are missing.

!= partial('slider_specials', { 'filter': 'special'  } )

Something like that works for me with a file in partials/ named slider_specials.html.jade
Reply all
Reply to author
Forward
0 new messages