Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] Added isNotEmpty method to HtmlString #34774

Merged
merged 1 commit into from Oct 9, 2020
Merged

Conversation

austenc
Copy link
Contributor

@austenc austenc commented Oct 9, 2020

When working with blade components I've often found myself reaching for an ->isNotEmpty() method on the default slot. This PR adds that method to HtmlString so that it feels more in line with other Laravel objects like collections.

Before

@if (!$slot->isEmpty())
    <span class="...">{{ $slot }}</span>
@endif

After

@if ($slot->isNotEmpty())
    <span class="...">{{ $slot }}</span>
@endif

The tests may not be necessary, but I decided it was better to submit the PR with tests than without them.

Thanks for considering!

@GrahamCampbell GrahamCampbell changed the title Added isNotEmpty method to HtmlString [8.x] Added isNotEmpty method to HtmlString Oct 9, 2020
@GrahamCampbell
Copy link
Member

I don't think this is necessary. The existing code is already clear, and fewer characters.

@austenc
Copy link
Contributor Author

austenc commented Oct 9, 2020

@GrahamCampbell couldn't you say that about many of the other isNotEmpty methods that exist in the framework too?

It may not be necessary, but it does make the class feel more congruent with other "emptyable" things in the framework. Two extra characters to have a more expressive statement seems worth it. 🤷

@taylorotwell taylorotwell merged commit 2e47b9c into laravel:8.x Oct 9, 2020
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.

None yet

3 participants