Repository navigation
$attributes onlyStartsWith and exceptStartsWith #38290
|
Regarding Blade components Attribute Bag. When developing headless Blade Components I miss two methods on the {{ $attributes->onlyStartsWith([...]) }}
{{ $attributes->exceptStartsWith([...]) }}Example use case <div {{ $attributes->onlyStartsWith(['wire:model', 'x-model']) }} >
<input
{{ $attributes->exceptStartsWith(['wire:model', 'x-model', 'x-data'])->merge(...) }}
@change="$dispatch(...)"
/>
</div>Current solution is a bit to verbose <div {{ $attributes->whereStartsWith('wire:model') }} {{ $attributes->whereStartsWith('x-model') }} >
<input
{{ $attributes->except('x-data')->whereDoesntStartWith('wire:model')->whereDoesntStartWith('x-model')->merge(...) }}
@change="$dispatch(...)"
/>
</div> |
Answered by
ryangjchandler
Aug 13, 2021
Replies: 2 comments 1 reply
|
Maybe filter() would work well for these use-cases.
|
0 replies
|
@tanthammar Despite the |
1 reply
Answer selected by
tanthammar
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@tanthammar Despite the
whereStartsWithandwhereDoesntStartWithDocBlocks saying it only accepts a string, you can actually pass an array to these methods as it's being passed toStr::startsWith($haystack, $needles)which accepts an array too.