Mixins for inject child blocks in parent mixin. This solution is temporary. I'm really looking forward to the release version 2.x.x jade, which is added support for Multiple Blocks in Mixins. In the meantime, we have to make do with what is.
Clone jade-injected to your project
git clone git://github.com/pavel-yagodin/jade-injected.git
Include jade file to your project
include jade-injected/jade-injected
Mixin
mixin parrent()
+injected: block
.parrent
+if('top')
.position-top
+use('top')
+if('box')
.position-boxes
+each('box')
.position-box
+use('box')
+else('box')
.position-empty
| Box is not inject
Usage
+parrent()
+inject('top')
| Text for top position
+inject('box')
| Text for first box
+inject('box')
| Text for second box
Result
<div class="parrent">
<div class="position-top">Text for top position</div>
<div class="position-boxes">
<div class="position-box">Text for first box</div>
<div class="position-box">Text for second box</div>
</div>
</div>
Since it's a temporary fix, there are some limitations.
mixin parrent()
+injected: block
this expamle has error
+parrent()
+inject('top')
| Text for top position
each item in boxes
+inject('box')
=item
+injected: block
Insert block to place. Please, if you call use mixin, check avariable.
+use(blockName)
+if(blockName)
+use(blockName)
+else(blockName)
=blockName + ' is not injected'
Each injected blocks
+each('box')
+use('box')
Injected blocks intro parrent mixin
+parrent
+inject('box')
| content