From d6d66b63a8d7994a0a5a3d98d1b5bdf0d42a42c9 Mon Sep 17 00:00:00 2001 From: Sergey Lukin Date: Mon, 7 Oct 2013 13:45:22 -0400 Subject: [PATCH 1/2] Keep @for environment inside @content block. Fixes #120 --- scss.inc.php | 3 ++- tests/inputs/content.scss | 8 ++++++++ tests/outputs/content.css | 6 ++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/scss.inc.php b/scss.inc.php index d57a5e3b..13f89f99 100644 --- a/scss.inc.php +++ b/scss.inc.php @@ -732,8 +732,9 @@ protected function compileChild($child, $out) { $this->throwError("Expected @content inside of mixin"); } + $strongTypes = array('include', 'block', 'for'); foreach ($content->children as $child) { - $this->storeEnv = ($child[0] == 'include' || $child[0] == 'block') + $this->storeEnv = (in_array($child[0], $strongTypes)) ? null : $content->scope; diff --git a/tests/inputs/content.scss b/tests/inputs/content.scss index 2bd62dcf..be6192a4 100644 --- a/tests/inputs/content.scss +++ b/tests/inputs/content.scss @@ -42,4 +42,12 @@ $color: white; } +@mixin respond-to($width) { + @media only screen and (min-width: $width) { @content; } +} +@include respond-to(40em) { + @for $i from 1 through 2 { + .grid-#{$i} { width: 100%; } + } +} diff --git a/tests/outputs/content.css b/tests/outputs/content.css index 0f71094e..3973903a 100644 --- a/tests/outputs/content.css +++ b/tests/outputs/content.css @@ -15,3 +15,9 @@ @media only screen and (max-width: 480px) { #sidebar { width: 100px; } } + +@media only screen and (min-width: 40em) { + .grid-1 { + width: 100%; } + .grid-2 { + width: 100%; } } From 4f79bfa841e378abb0c0d7c61ccd0201d4dfd79d Mon Sep 17 00:00:00 2001 From: Sergey Lukin Date: Mon, 7 Oct 2013 13:54:33 -0400 Subject: [PATCH 2/2] Keep @while environment inside @content block. Fixes #121 --- scss.inc.php | 2 +- tests/inputs/content.scss | 8 ++++++++ tests/outputs/content.css | 6 ++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/scss.inc.php b/scss.inc.php index 13f89f99..92119ed2 100644 --- a/scss.inc.php +++ b/scss.inc.php @@ -732,7 +732,7 @@ protected function compileChild($child, $out) { $this->throwError("Expected @content inside of mixin"); } - $strongTypes = array('include', 'block', 'for'); + $strongTypes = array('include', 'block', 'for', 'while'); foreach ($content->children as $child) { $this->storeEnv = (in_array($child[0], $strongTypes)) ? null diff --git a/tests/inputs/content.scss b/tests/inputs/content.scss index be6192a4..55ca04e8 100644 --- a/tests/inputs/content.scss +++ b/tests/inputs/content.scss @@ -51,3 +51,11 @@ $color: white; .grid-#{$i} { width: 100%; } } } + +@include respond-to(40em) { + $i: 1; + @while $i <= 2 { + .grid-#{$i} { width: 100%; } + $i: $i + 1; + } +} diff --git a/tests/outputs/content.css b/tests/outputs/content.css index 3973903a..6657a216 100644 --- a/tests/outputs/content.css +++ b/tests/outputs/content.css @@ -21,3 +21,9 @@ width: 100%; } .grid-2 { width: 100%; } } + +@media only screen and (min-width: 40em) { + .grid-1 { + width: 100%; } + .grid-2 { + width: 100%; } }