Skip to content

Commit f7c9a49

Browse files
author
Dan Diemer
committed
Let @content work when a block isn’t passed in.
1 parent c91da17 commit f7c9a49

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

src/Compiler.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1723,7 +1723,9 @@ protected function compileChild($child, OutputBlock $out)
17231723
?: $this->get(self::$namespaces['special'] . 'content', false, $this->env);
17241724

17251725
if (! $content) {
1726-
$this->throwError('Expected @content inside of mixin');
1726+
$content = new \stdClass();
1727+
$content->scope = new \stdClass();
1728+
$content->children = $this->storeEnv->parent->block->children;
17271729
break;
17281730
}
17291731

tests/inputs/content.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,12 @@ A {
116116
display: none;
117117
}
118118
}
119+
120+
@mixin empty_content() {
121+
@content;
122+
}
123+
.test_empty_content {
124+
display: inline;
125+
font-weight: bold;
126+
@include empty_content()
127+
}

tests/outputs/content.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,7 @@ A {
3636

3737
.test {
3838
display: none; }
39+
40+
.test_empty_content {
41+
display: inline;
42+
font-weight: bold; }

tests/outputs_numbered/content.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,7 @@ A {
4545
/* line 114, inputs/content.scss */
4646
.test {
4747
display: none; }
48+
/* line 123, inputs/content.scss */
49+
.test_empty_content {
50+
display: inline;
51+
font-weight: bold; }

0 commit comments

Comments
 (0)