Mentalhead
Mentalhead

Reputation: 1505

Multiple blocks in Jade mixin

I was just wondering is there a way to add multiple blocks to 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 is there a way to use multiple blocks with different content in Jade mixin like this:

mixin article
 block
 p Mixin paragraph
 block

Bear in mind that using:

+article
 p This is my first block

will produce a duplicated output (it will display "This is my first block twice") like this:

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

Which is not what I am trying to do.

Basically what I'm asking is can I 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 can I use two or more different blocks, with different content of course, with a Jade mixin, or am I just limited to one block per mixin?

Upvotes: 4

Views: 2875

Answers (1)

Mentalhead
Mentalhead

Reputation: 1505

I've posted the similar thread on Jade's GitHub issue section:

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

Currently, we don't support that, you can repeat the block keyword, but it will just repeat the same block multiple times. There is some work going in to adapting how mixins work though, so this may be something we support in the future.

Upvotes: 4

Related Questions