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

[6.x] Added `unless` condition to Blade custom `if` directives #30492

Merged
merged 2 commits into from Nov 1, 2019

Conversation

@kitbs
Copy link
Contributor

kitbs commented Nov 1, 2019

The Blade::if() method currently automatically registers the following directives (using the example "custom" as the $name argument):

  • @custom (positive if condition)
  • @elsecustom (elseif condition)
  • @endcustom (endif)

This PR registers an additional @unlesscustom directive (a negative if condition).

To illustrate, the example in the docs is:

@env('local')
    // The application is in the local environment...
@elseenv('testing')
    // The application is in the testing environment...
@else
    // The application is not in the local or testing environment...
@endenv

This PR would enable the following:

@unlessenv('production')
    // The application is not in the production environment...
@endenv

This simple case would otherwise have to be done with an empty first condition, e.g.:

@env('production')
@else
    // The application is not in the production environment...
@endenv

This feels like a minor non-breaking change, so I've submitted to the 6.x branch. Apologies if I've got this wrong.

kitbs added 2 commits Oct 29, 2019
@GrahamCampbell GrahamCampbell changed the title Added `unless` condition to Blade custom `if` directives [6.x] Added `unless` condition to Blade custom `if` directives Nov 1, 2019
@taylorotwell taylorotwell merged commit 0facb7b into laravel:6.x Nov 1, 2019
2 checks passed
2 checks passed
continuous-integration/styleci/pr The analysis has passed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.