How to pass a HTML element as an argument to a pug mixin

35 Views Asked by At

I'd like to pass HTML through to my mixin.

Something like this:

mixin complexElement
    .container
        block header
        block content
        p This is some other content in the container.
        block footer

+complexElement
    block header
        h1 This is the Header
    block content
        p This is the main content.
    block footer
        p This is the footer.

Any ideas?

1

There are 1 best solutions below

0
Sean On

Mixins don't support multiple named blocks. They only support a single unnamed block: https://pugjs.org/language/mixins.html#mixin-blocks.

You could nest mixins, and create a mixin each for the container, header, content, and footer. Or if the data is uniform enough, you could pass it all as an object to the one mixin.