Skip to content

[10.x] Improved Handling of Empty Component Slots with HTML Comments or Line Breaks - #49966

Merged
taylorotwell merged 4 commits into
laravel:10.xfrom
comes:alt-filtered-contents
Feb 9, 2024
Merged

[10.x] Improved Handling of Empty Component Slots with HTML Comments or Line Breaks#49966
taylorotwell merged 4 commits into
laravel:10.xfrom
comes:alt-filtered-contents

Conversation

@comes

@comes comes commented Feb 3, 2024

Copy link
Copy Markdown
Contributor

This PR is an alternate implementation for the problem that PR #49935 addresses.

A short summary:

Since Livewire is injecting morph markers, we cannot safely ask if a slot is empty or not. The same happens if we add a linebreak or nonprintable characters like whitespaces or tabs. The slot is not empty and should be rendered.

This PR provide a new function $slot->sanitizedEmpty() and the counterpart $slot->sanitizedNotEmpty()

01    <table>
02    @if($slot-> sanitizedNotEmpty())
03        {{ $slot }}
04    @else
05        <tr><td>{{ __('No Results') }}</td></tr>
06    @endif
07    </table>

Please decide which one fits better in the framework.

Please note, the method is renamed into hasActualContent()

@comes
comes marked this pull request as draft February 3, 2024 15:09
@github-actions

github-actions Bot commented Feb 3, 2024

Copy link
Copy Markdown

Thanks for submitting a PR!

Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@comes
comes marked this pull request as ready for review February 3, 2024 15:12
@comes comes changed the title [10.x] Alternative implementation for PR#49935 [10.x] Improved Handling of Empty Component Slots with HTML Comments or Line Breaks (Alternative to PR#49935) Feb 3, 2024
@driesvints driesvints changed the title [10.x] Improved Handling of Empty Component Slots with HTML Comments or Line Breaks (Alternative to PR#49935) [10.x] Improved Handling of Empty Component Slots with HTML Comments or Line Breaks Feb 7, 2024
@taylorotwell
taylorotwell merged commit 856d1bf into laravel:10.x Feb 9, 2024
@comes
comes deleted the alt-filtered-contents branch February 10, 2024 11:04
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.

2 participants