Permalink
Browse files

Use explicit `block` notation

Blocks should not be passed along to junior mixins automatically.  They should work just like normal in a mixin call's block:

```
mixin bar
  block

mixin foo
  +bar
    block

+foo
  p Hello world!
```
  • Loading branch information...
1 parent 66a221b commit 8ec78bbad94596084146216387d844e0af8a416b @chowey chowey committed Apr 29, 2012
Showing with 4 additions and 7 deletions.
  1. +3 −7 lib/compiler.js
  2. +1 −0 test/cases/mixin.blocks.jade
View
@@ -236,7 +236,7 @@ Compiler.prototype = {
// Block keyword has a special meaning in mixins
if (this.parentIndents && block.mode) {
if (pp) this.buf.push("__indent.push('" + Array(this.indents + 1).join(' ') + "');")
- this.buf.push('block && this.block();');
+ this.buf.push('block && block();');
if (pp) this.buf.push("__indent.pop();")
return;
}
@@ -307,16 +307,12 @@ Compiler.prototype = {
this.buf.push('}});');
}
} else {
- if (args) {
- this.buf.push(name + '.call(this, ' + args + ');');
- } else {
- this.buf.push(name + '.call(this);');
- }
+ this.buf.push(name + '(' + args + ');');
}
if (pp) this.buf.push("__indent.pop();")
} else {
this.buf.push('var ' + name + ' = function(' + args + '){');
- this.buf.push('var block = !!this.block;');
+ this.buf.push('var block = this.block;');
this.parentIndents++;
this.visit(mixin.block);
this.parentIndents--;
@@ -29,6 +29,7 @@ mixin bar()
mixin foo()
#foo
+bar
+ block
+foo
p one

0 comments on commit 8ec78bb

Please sign in to comment.