Skip to content

lise-yy/jade-injected

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

jade-injected

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.

Install

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

NPM

Usage

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>

Wraning

Since it's a temporary fix, there are some limitations.

Do not use a block if +injected called in mixin.

mixin parrent()
    +injected: block

Do not use data cycles (hopefully should be fixed soon)

this expamle has error
+parrent()
    +inject('top')
        | Text for top position
    each item in boxes
        +inject('box')
            =item

Mixins

Initialization inject into mixin

+injected: block

Use block

Insert block to place. Please, if you call use mixin, check avariable.

+use(blockName)

If-Else

+if(blockName)
    +use(blockName)
+else(blockName)
    =blockName + ' is not injected'

Each

Each injected blocks

+each('box')
    +use('box')

Inject

Injected blocks intro parrent mixin

+parrent
    +inject('box')
        | content

About

JADE Mixins injected & use blocks

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages