-
Notifications
You must be signed in to change notification settings - Fork 1
Description
At Erin's request:
My Wishlist for Blade:
Automatic unwrapping of Value/Values objects or getting rid of them entirely
This would do away with the remaining single biggest annoyance with Blade, this doesn't work and it isn't immediately evident why (to newcomers):
@if ($field_name === 'value')I think getting rid of them should be possible if/when fetching data is more performant using Stache in SQLite - https://github.com/ryanmitchell/statamic-stache-sqlite
Auto importing of the value/modify helpers
When you do need to reach for the helpers I constantly find my self scrolling up to the top of the file to double check the import is there. And the one time I assume it is there, it isn't.
@php
use function Statamic\View\Blade\{value};
@endphpA tag() helper (similar to the value/modify)
Does what it says on the tin, makes it easier to use Statamic::tag() without the need for the classname. Makes if statements with the tag shorter.
@if (tag('user:can')->do('edit blog entries')->fetch())I know this is a poor example because you can do auth()->user()->can()
Automatic "fetching" of the value when using the modify helper
This would see the current underlying value and allow casting to a string, array, collection (whatever makes sense given the data)
For example:
{{ modify('this is a string')->replace('is a', 'is a short') }}In this case it knows it is a string it doesn't need fetch to know that. I am pretty sure if the object implements Stringable Laravel Blade will autocast it to a string when trying to output it. Same could be done with Arrayable I believe.
I'll add more to this if I think of it, but these are what I can think of off the top of my head.