From cded9d9288cacbde0b42512e898ef30ac59ef1dd Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Tue, 8 Sep 2026 12:04:52 +0100 Subject: [PATCH] keep augmentable tag results as objects inside antlers interpolations Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01YENbpFdMXXA4j68iM7Dog2 --- .../Language/Runtime/NodeProcessor.php | 12 +++++++++- tests/Antlers/Runtime/TagsTest.php | 22 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/View/Antlers/Language/Runtime/NodeProcessor.php b/src/View/Antlers/Language/Runtime/NodeProcessor.php index 59f964c51b9..593562458d5 100644 --- a/src/View/Antlers/Language/Runtime/NodeProcessor.php +++ b/src/View/Antlers/Language/Runtime/NodeProcessor.php @@ -57,6 +57,7 @@ use Statamic\View\Cascade; use Statamic\View\Slot; use Statamic\View\State\CachesOutput; +use Stringable; use Throwable; class NodeProcessor @@ -1802,7 +1803,9 @@ public function reduce($processNodes) $output = RuntimeValues::resolveWithRuntimeIsolation($output); } - $output = PathDataManager::reduceForAntlers($output, $this->antlersParser, $this->getActiveData(), $node->isClosedBy != null); + if (! $this->interpolatingAugmentable($output)) { + $output = PathDataManager::reduceForAntlers($output, $this->antlersParser, $this->getActiveData(), $node->isClosedBy != null); + } } if ($this->isInterpolationProcessor) { @@ -2512,6 +2515,13 @@ public function reduce($processNodes) return $buffer; } + private function interpolatingAugmentable($output): bool + { + return $this->isInterpolationProcessor + && $output instanceof Augmentable + && $output instanceof Stringable; + } + /** * Executes any PHP within the provided buffer and returns the result. * diff --git a/tests/Antlers/Runtime/TagsTest.php b/tests/Antlers/Runtime/TagsTest.php index 2636dc3938b..f707d037439 100644 --- a/tests/Antlers/Runtime/TagsTest.php +++ b/tests/Antlers/Runtime/TagsTest.php @@ -2,6 +2,10 @@ namespace Tests\Antlers\Runtime; +use Illuminate\Http\UploadedFile; +use Illuminate\Support\Facades\Storage; +use Statamic\Facades\Asset; +use Statamic\Facades\AssetContainer; use Statamic\Tags\Tags; use Tests\Antlers\ParserTestCase; @@ -46,4 +50,22 @@ public function index() $this->assertSame('b', $this->renderString('{{ test_tag }}{{ a }}{{ /test_tag }}', [], true)); } + + /** + * @see https://github.com/statamic/cms/issues/11257 + */ + public function test_objects_returned_from_tags_keep_their_data_when_assigned_to_a_variable() + { + Storage::fake('test', ['url' => '/assets']); + Storage::disk('test')->put('a.jpg', UploadedFile::fake()->image('a.jpg')->getContent()); + tap(AssetContainer::make('test')->disk('test'))->save(); + Asset::find('test::a.jpg')->data(['alt' => 'Alpha'])->save(); + + $template = <<<'EOT' +{{ img = { asset url="/assets/a.jpg" } }} +{{ img }}|{{ img.url }}|{{ img.alt }}|{{ img:alt }} +EOT; + + $this->assertSame('/assets/a.jpg|/assets/a.jpg|Alpha|Alpha', trim($this->renderString($template, [], true))); + } }