Skip to content

Commit

Permalink
Merge pull request #122 from sergeylukin/mixin-content-for-env
Browse files Browse the repository at this point in the history
Keep @for environment inside @content block. Fixes #120
  • Loading branch information
leafo committed Oct 7, 2013
2 parents 96329a5 + 4f79bfa commit bc9d634
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
3 changes: 2 additions & 1 deletion scss.inc.php
Expand Up @@ -732,8 +732,9 @@ protected function compileChild($child, $out) {
$this->throwError("Expected @content inside of mixin");
}

$strongTypes = array('include', 'block', 'for', 'while');
foreach ($content->children as $child) {
$this->storeEnv = ($child[0] == 'include' || $child[0] == 'block')
$this->storeEnv = (in_array($child[0], $strongTypes))
? null
: $content->scope;

Expand Down
16 changes: 16 additions & 0 deletions tests/inputs/content.scss
Expand Up @@ -42,4 +42,20 @@ $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%; }
}
}

@include respond-to(40em) {
$i: 1;
@while $i <= 2 {
.grid-#{$i} { width: 100%; }
$i: $i + 1;
}
}
12 changes: 12 additions & 0 deletions tests/outputs/content.css
Expand Up @@ -15,3 +15,15 @@
@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%; } }

@media only screen and (min-width: 40em) {
.grid-1 {
width: 100%; }
.grid-2 {
width: 100%; } }

0 comments on commit bc9d634

Please sign in to comment.