statamic / v2-hub

Statamic 2 - Feature Requests and Bug Reports
https://statamic.com
95 stars 5 forks source link

`collection` variable not working in a collection loop #2400

Open 1stevengrant opened 5 years ago

1stevengrant commented 5 years ago

When looping over a collection like

{{ collection from="blog|another" }} inside the loop, if I want to see what collection the entry belongs to, I can do {{collection}} but not {{ collection }}

jackmcdade commented 5 years ago

What the heck lol

jackmcdade commented 5 years ago

Try replacing line 499 in core\views\Antlers\Parser.php with the following:

// if (preg_match($nested_regex, $content . $match[0][0], $nested_matches)) {
if (preg_match($nested_regex, $content, $nested_matches)) {

It looks like a solid fix, but it's a funky weird edge case that I don't have tests for and don't want to push this change if it's gonna break other stuff.