Skip to content

Commit ea6759e

Browse files
committed
Handle collections. Fixes issue introduced in 6d36145
1 parent 5a8408d commit ea6759e

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/View/Antlers/Parser.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,10 @@ public function parseCallbackTags($text, $data)
595595
}
596596

597597
if (! empty($values)) {
598+
if ($values instanceof Collection) {
599+
$values = $values->all();
600+
}
601+
598602
if (Arr::isAssoc($values)) {
599603
$replacement = $this->parse($content, array_merge($data, $values));
600604
} else {

tests/View/Antlers/ParserTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,15 @@ public function testArrayModifiersGetParsed()
521521
$this->assertEquals('one', $this->parse($template, $this->variables));
522522
}
523523

524+
public function testArrayModifiersOnCollectionsGetParsed()
525+
{
526+
$template = '{{ simple limit="1" }}{{ value }}{{ /simple }}';
527+
528+
$this->assertEquals('one', $this->parse($template, [
529+
'simple' => collect(['one', 'two', 'three']),
530+
]));
531+
}
532+
524533
public function testRecursiveChildren()
525534
{
526535
// the variables are inside RecursiveChildren@index

0 commit comments

Comments
 (0)