Last active
October 15, 2017 14:46
-
-
Save dek4nice/6aecb4a7c0c4470fb22236d8dffc8e9f to your computer and use it in GitHub Desktop.
Multiple blocks in Jade/Pug mixins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //- Multiple blocks in jade mixins? #1693 | |
| //- https://github.com/pugjs/pug/issues/1693 | |
| //- [Issue on github] | |
| //- https://github.com/pugjs/pug/issues/1693 | |
| h2 Issue | |
| p | |
| a(href='https://github.com/pugjs/pug/issues/1693' , target="_blank") Multiple blocks in jade mixins? | |
| hr | |
| //- [Defines] | |
| - BlockAmbry = {} | |
| mixin block-set(mixin , blockid) | |
| if block | |
| - BlockAmbry[mixin] = BlockAmbry[mixin] || {} | |
| - BlockAmbry[mixin][blockid] = function() { return block.call(this) }; | |
| mixin block-call(mixin , blockid) | |
| - BlockAmbry[mixin][blockid].call(); | |
| //- [Example mixin] | |
| mixin example-mixin-name(name , cb) | |
| block | |
| .template | |
| .layout-left | |
| +block-call('example-mixin-name','layout-left') | |
| .layout-right | |
| +block-call('example-mixin-name','layout-right') | |
| //- [Here we go...] | |
| .wrapper | |
| //- set before mixin call... | |
| +block-set('example-mixin-name','layout-left') | |
| p lorem ipsum | |
| +block-set('example-mixin-name','layout-right') | |
| p dolor sit amet | |
| +example-mixin-name() | |
| //- ...or within block | |
| +example-mixin-name() | |
| +block-set('example-mixin-name','layout-left') | |
| p consectetur adipiscing elit | |
| +block-set('example-mixin-name','layout-right') | |
| p sed do eiusmod tempor | |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Issue
pugjs/pug#1693