Skip to content

Commit bc9d634

Browse files
committed
Merge pull request leafo#122 from sergeylukin/mixin-content-for-env
Keep @for environment inside @content block. Fixes leafo#120
2 parents 96329a5 + 4f79bfa commit bc9d634

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

scss.inc.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,8 +732,9 @@ protected function compileChild($child, $out) {
732732
$this->throwError("Expected @content inside of mixin");
733733
}
734734

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

tests/inputs/content.scss

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,20 @@ $color: white;
4242
}
4343

4444

45+
@mixin respond-to($width) {
46+
@media only screen and (min-width: $width) { @content; }
47+
}
48+
49+
@include respond-to(40em) {
50+
@for $i from 1 through 2 {
51+
.grid-#{$i} { width: 100%; }
52+
}
53+
}
4554

55+
@include respond-to(40em) {
56+
$i: 1;
57+
@while $i <= 2 {
58+
.grid-#{$i} { width: 100%; }
59+
$i: $i + 1;
60+
}
61+
}

tests/outputs/content.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,15 @@
1515
@media only screen and (max-width: 480px) {
1616
#sidebar {
1717
width: 100px; } }
18+
19+
@media only screen and (min-width: 40em) {
20+
.grid-1 {
21+
width: 100%; }
22+
.grid-2 {
23+
width: 100%; } }
24+
25+
@media only screen and (min-width: 40em) {
26+
.grid-1 {
27+
width: 100%; }
28+
.grid-2 {
29+
width: 100%; } }

0 commit comments

Comments
 (0)