Skip to content

Commit

Permalink
[5.x] Corrects issue returning some collections from tags (#10113)
Browse files Browse the repository at this point in the history
Co-authored-by: Jason Varga <[email protected]>
  • Loading branch information
JohnathonKoster and jasonvarga authored May 20, 2024
1 parent bad5b3a commit c84a8a7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static function resolveWithRuntimeIsolation($augmentable)
{
GlobalRuntimeState::$requiresRuntimeIsolation = true;
try {
if ($augmentable instanceof Collection && $augmentable->count() && $augmentable[0] instanceof Augmentable) {
if ($augmentable instanceof Collection && $augmentable->first() instanceof Augmentable) {
$value = BulkAugmentor::make($augmentable)->toArray();
} else {
$value = $augmentable->toDeferredAugmentedArray();
Expand Down
15 changes: 15 additions & 0 deletions tests/Antlers/Runtime/TagsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,19 @@ public function index()

$this->assertSame('Test: test valuetest value - ', $result);
}

public function test_collections_returned_from_tags()
{
(new class extends Tags
{
public static $handle = 'test_tag';

public function index()
{
return collect(['a' => 'b']);
}
})::register();

$this->assertSame('b', $this->renderString('{{ test_tag }}{{ a }}{{ /test_tag }}', [], true));
}
}

0 comments on commit c84a8a7

Please sign in to comment.