Skip to content

Conversation

@riasvdv
Copy link
Contributor

@riasvdv riasvdv commented Oct 23, 2020

This uses the code in https://github.com/statamic/cms/blob/master/src/View/Antlers/Engine.php#L133-L152 to return the output of a tag, it might be worth to extract this piece and make it available on the Engine.

This allows Blade to do the following:

@foreach (tag('collection:news', ['limit' => 1]) as $entry)
    {{ $entry->get('title') }}
@endforeach

I don't know that much of the Engine/Antlers internals, so if there's a better way to do this I'm all for it!

It's also missing augmentation, not sure how to handle that

This uses the code in https://github.com/statamic/cms/blob/master/src/View/Antlers/Engine.php#L133-L152 to return the output of a tag, it might be worth to extract this piece and make it available on the Engine.

This allows Blade to do the following:

```
@foreach (tag('collection:news', ['limit' => 1]) as $entry)
    {{ $entry->get('title') }}
@Endforeach
```

I don't know that much of the Engine/Antlers internals, so if there's a better way to do this I'm all for it!
@jasonvarga
Copy link
Member

Thanks for this. Once again though, same thought as on #2717 - introducing a global function.

If that chunk of code can be put somewhere reusable like you're suggesting, the tag function could end up also being a one liner that people could just copy into their projects.

@edalzell
Copy link
Contributor

@riasvdv I've got the @collection directive in my addon, that's another option than making these.

@jasonvarga
Copy link
Member

This would be useful for any tag, rather than making a directive for each tag.

@jasonvarga
Copy link
Member

Gonna hold off on this for now and suggest devs plop it in their own helpers file. Thanks!

@jasonvarga jasonvarga closed this Nov 23, 2020
@jesseleite jesseleite mentioned this pull request Jan 11, 2022
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants