diff --git a/scss.inc.php b/scss.inc.php index cc2ba60a..0d8978c7 100644 --- a/scss.inc.php +++ b/scss.inc.php @@ -687,13 +687,20 @@ protected function compileChild($child, $out) { $this->throwError("Unexpected @content inside of mixin"); } - $this->storeEnv = $content->scope; + if(is_object($content)) { + $this->storeEnv = $content->scope; + if(count($content->children) > 0) { + foreach ($content->children as $child) { + if($child[0] == "include" || $child[0] == "block") { + $this->storeEnv = @$content->parent; + } + $this->compileChild($child, $out); + $this->storeEnv = $content->scope; + } + } - foreach ($content->children as $child) { - $this->compileChild($child, $out); + unset($this->storeEnv); } - - unset($this->storeEnv); break; case "debug": list(,$value, $pos) = $child; diff --git a/tests/inputs/mixins.scss b/tests/inputs/mixins.scss index 9baffc17..9cf55dd4 100644 --- a/tests/inputs/mixins.scss +++ b/tests/inputs/mixins.scss @@ -97,3 +97,46 @@ div { color: blue; } } + + +// mixin content (http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#mixin-content) +@mixin content-simple { + div.mixin-content-simple { + @content; + } +} + +@mixin content-with-arg ( $background ) { + div.mixin-content-with-arg { + background: $background; + @content; + } +} + +@include content-simple { + color: red; +} + +@include content-with-arg($background: blue) { + color: red; +} + +@include content-with-arg($background: purple) { + @include hello_world; +} + +@include content-simple { + @include cool(10px, 12px, 21px); +} + +@include content-simple { + @include something(orange); +} + +@include content-with-arg($background: purple) { + @include cool(10px, 12px, 21px); +} + +@include content-with-arg($background: purple) { + @include something(orange); +} \ No newline at end of file diff --git a/tests/outputs/mixins.css b/tests/outputs/mixins.css index 27398a9b..89cee582 100644 --- a/tests/outputs/mixins.css +++ b/tests/outputs/mixins.css @@ -44,3 +44,32 @@ div p { top: 0; } div p .top div { color: red; } + +div.mixin-content-simple { + color: red; } + +div.mixin-content-with-arg { + background: blue; + color: red; } + +div.mixin-content-with-arg { + background: purple; + height: 20px; } + +div.mixin-content-simple { + height: 43px; } + +div.mixin-content-simple { + color: orange; } + div.mixin-content-simple div { + height: 20px; } + +div.mixin-content-with-arg { + background: purple; + height: 43px; } + +div.mixin-content-with-arg { + background: purple; + color: orange; } + div.mixin-content-with-arg div { + height: 20px; }