Skip to content

Commit

Permalink
Handle collections. Fixes issue introduced in 6d36145
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga committed Sep 4, 2020
1 parent 5a8408d commit ea6759e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/View/Antlers/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,10 @@ public function parseCallbackTags($text, $data)
}

if (! empty($values)) {
if ($values instanceof Collection) {
$values = $values->all();
}

if (Arr::isAssoc($values)) {
$replacement = $this->parse($content, array_merge($data, $values));
} else {
Expand Down
9 changes: 9 additions & 0 deletions tests/View/Antlers/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,15 @@ public function testArrayModifiersGetParsed()
$this->assertEquals('one', $this->parse($template, $this->variables));
}

public function testArrayModifiersOnCollectionsGetParsed()
{
$template = '{{ simple limit="1" }}{{ value }}{{ /simple }}';

$this->assertEquals('one', $this->parse($template, [
'simple' => collect(['one', 'two', 'three']),
]));
}

public function testRecursiveChildren()
{
// the variables are inside RecursiveChildren@index
Expand Down

0 comments on commit ea6759e

Please sign in to comment.