Jade include with parameter
Asked Answered
M

1

17

In an older version of Jade I was able to include partials and pass variables into them like this:

!=partial('partials/video', {title:video.title, artist:video.artist})

now the partial connotation does not exist any more. How do I achieve the same thing using the include connotations?

Modulation answered 21/6, 2016 at 5:24 Comment(0)
E
30

You can use mixins for that. Wrap your include content inside a mixin and call the mixin function in your pug file. See my example below.

include-file.pug

mixin my-include(title, description)
  h1= title
  p= description

index.pug

include include-file
html
  head
  body
    +my-include('my title', 'my description')
Eastwards answered 24/9, 2017 at 23:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.