From 2979b0d5b6ce6fff852e74f4da57f44b953dea00 Mon Sep 17 00:00:00 2001 From: James Shannon Date: Thu, 11 Apr 2013 12:38:40 -0700 Subject: [PATCH 1/4] Mixin @content with embedded mixin test cases @include inside of a @content block causes issues --- tests/inputs/mixins.scss | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) 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 From dd5349316dcc39305201d9dbbb4e5489ae6a1773 Mon Sep 17 00:00:00 2001 From: Christian Brandt Date: Wed, 24 Apr 2013 11:20:42 +0200 Subject: [PATCH 2/4] fixes issue #87 at leafo/scssphp --- scss.inc.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/scss.inc.php b/scss.inc.php index cc2ba60a..bac03f35 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") {//} && !is_null($content->parent)) { + $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; From 2db007a141b1de9ca11d60b198b5d33d0464c60b Mon Sep 17 00:00:00 2001 From: Christian Brandt Date: Wed, 24 Apr 2013 11:28:21 +0200 Subject: [PATCH 3/4] removed comment --- scss.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scss.inc.php b/scss.inc.php index bac03f35..0d8978c7 100644 --- a/scss.inc.php +++ b/scss.inc.php @@ -691,7 +691,7 @@ protected function compileChild($child, $out) { $this->storeEnv = $content->scope; if(count($content->children) > 0) { foreach ($content->children as $child) { - if($child[0] == "include" || $child[0] == "block") {//} && !is_null($content->parent)) { + if($child[0] == "include" || $child[0] == "block") { $this->storeEnv = @$content->parent; } $this->compileChild($child, $out); From 1220355ed70bfd16d5865c6c8f17543a3590f5af Mon Sep 17 00:00:00 2001 From: Christian Brandt Date: Wed, 24 Apr 2013 18:31:36 +0200 Subject: [PATCH 4/4] added test mixins output --- tests/outputs/mixins.css | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) 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; }