From 54488fb09d4ae9ef990269eefe4c16fe9ea58748 Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Wed, 2 Sep 2026 09:58:44 +0100 Subject: [PATCH] only treat paired slot tags as named slot definitions `checkPartialForNamedSlots` picked up non-paired `{{ slot:title }}` output tags inside a nested partial pair, reducing them to empty strings and overwriting the real slot content. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01TDjs3WSZv7K4p2bX6e1DZ9 --- .../Language/Runtime/NodeProcessor.php | 2 +- tests/Antlers/Runtime/PartialsTest.php | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) 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)); + } }