Several blocks in the Jade mixin

I'm just wondering if there is a way to add multiple blocks to the Jade mixin.

For example, you can use this code:

mixin article
 block
 p Mixin paragraph


+article
 p This is my first block

      

However, I want to know if there is a way to use multiple blocks with different content in the Jade mixin like this:

mixin article
 block
 p Mixin paragraph
 block

      

Remember using:

+article
 p This is my first block

      

will create duplicate output (it will display "This is my first block twice"):

<p>This is my first block</p>
<p>Mixin paragraph</p>
<p>This is my first block</p>

      

This is not what I am trying to do.

Basically, I am asking if I can use this kind of mixin:

mixin article
 block
 p Mixin paragraph
 block
 block

      

And get the following HTML output:

<p>This is my first block</p>
<p>Mixin paragraph</p>
<p>This is my second block</p>
<p>This is my third block</p>

      

I just want to know if I can use two or more different blocks with different content, of course with the Jade mixin, or am I just limited to one block per mixin?

+3


source to share


1 answer


I posted a similar thread in the Jade GitHub question section:

https://github.com/tj/jade/issues/1693



We do not currently support this, you can repeat the block keyword, but it will just repeat the same block multiple times. There is some work on adapting how mixins work, so this might be something we support in the future.

+4


source







All Articles