The current Blade documentation shows two approaches for using Statamic features in Blade:
- Antlers Blade Components (
<s:glide>) - verbose for simple use cases
- Fluent tags (
Statamic::tag('glide')) - awkward syntax, not discoverable
However, there's a cleaner approach using facades that isn't documented at all.
For example: Image Manipulation (Glide), the docs currently show:
{{-- Using fluent tags --}}
<img src="{{
Statamic::tag('glide')->src('test.png')->width(1280)->height(800)->fetch() }}"
/>
{{-- Using Antlers Blade Components --}}
<s:glide src="test.png" width="1280" height="800">
<img src="{{ $url }}" />
</s:glide>
The second approach is clunky if you're just wanting the URL, so you're forced to use Statamic::tag() everywhere if you just want the data, but there's a much cleaner facade approach that isn't documented:
<img src="{{ Image::manipulate('test.png', ['w' => 1280, 'h' => 800]) }}" />
I prefer using Facades because it's more Laravel-like and familiar to developers, and also better IDE autocomplete support. It's also a cleaner syntax for simple use cases.
Suggestion
The Blade documentation should include a section showing facade equivalents for common Antlers tags. For example:
Collections:
// Instead of: Statamic::tag('collection:wheels')->limit(3)
Collection::findByHandle('wheels')->queryEntries()->limit(3)->get()
Taxonomies:
// Instead of: <s:taxonomy:categories>
Taxonomy::findByHandle('categories')
Navigation:
// Instead of: <s:nav:main>
Nav::find('main')->tree()
This would help developers transitioning from Antlers or building custom Blade components discover the most appropriate API for their needs.
The current Blade documentation shows two approaches for using Statamic features in Blade:
<s:glide>) - verbose for simple use casesStatamic::tag('glide')) - awkward syntax, not discoverableHowever, there's a cleaner approach using facades that isn't documented at all.
For example: Image Manipulation (Glide), the docs currently show:
The second approach is clunky if you're just wanting the URL, so you're forced to use
Statamic::tag()everywhere if you just want the data, but there's a much cleaner facade approach that isn't documented:I prefer using Facades because it's more Laravel-like and familiar to developers, and also better IDE autocomplete support. It's also a cleaner syntax for simple use cases.
Suggestion
The Blade documentation should include a section showing facade equivalents for common Antlers tags. For example:
Collections:
Taxonomies:
Navigation:
This would help developers transitioning from Antlers or building custom Blade components discover the most appropriate API for their needs.