diff --git a/src/View/Antlers/Language/Runtime/NodeProcessor.php b/src/View/Antlers/Language/Runtime/NodeProcessor.php index 1d7bf42b81a..a20730d1080 100644 --- a/src/View/Antlers/Language/Runtime/NodeProcessor.php +++ b/src/View/Antlers/Language/Runtime/NodeProcessor.php @@ -1137,7 +1137,7 @@ protected function checkPartialForNamedSlots(AntlersNode $node) $namedSlots = []; foreach ($node->children as $child) { - if ($child instanceof AntlersNode && ! $child->isComment && $child->name->name == 'slot') { + if ($child instanceof AntlersNode && ! $child->isComment && $child->isPaired() && $child->name->name == 'slot') { $namedSlots[$child->name->methodPart] = $child; } } diff --git a/tests/Antlers/Runtime/PartialsTest.php b/tests/Antlers/Runtime/PartialsTest.php index 223a3f2c555..bb0172bd71b 100644 --- a/tests/Antlers/Runtime/PartialsTest.php +++ b/tests/Antlers/Runtime/PartialsTest.php @@ -95,4 +95,27 @@ public function test_assignments_in_earlier_partials_do_not_blank_a_later_partia $this->assertSame('FILTERhiKEEPME', $this->renderString($template, [], true)); } + + public function test_named_slots_render_inside_a_nested_partial_that_uses_the_default_slot() + { + $template = <<<'EOT' +{{ partial:accordion index="1" }} + {{ slot:title }}

The Title

{{ /slot:title }} + {{ slot:icon }}{{ /slot:icon }} + {{ slot:body }}

The Body

{{ /slot:body }} +{{ /partial:accordion }} +EOT; + + $accordion = <<<'EOT' +
{{ partial:flex_column class="p-6" }}
{{ slot:title }}{{ slot:icon }}
{{ slot:body }}
{{ /partial:flex_column }}
+EOT; + + $this->withFakeViews(); + $this->viewShouldReturnRaw('accordion', $accordion); + $this->viewShouldReturnRaw('flex_column', '
{{ slot }}
'); + + $expected = '

The Title

The Body

'; + + $this->assertSame($expected, $this->renderString($template, [], true)); + } }