A tidy conditional Blade directive for checking if something is in an array.
This package provides a small @in
directive that allows you to simplify in_array
checks inside of your Blade views.
Installation
You can install the package via Composer:
composer require ryangjchandler/blade-in-directive
Usage
You can use the @in
directive in the same way as the @if
directive.
@in('foo', ['foo', 'bar'])
Hey, I found it.
@endin
Behind the scenes, it's being simplified to an if (in_array('foo', ['foo', 'bar']))
statement.
You can also do strict checks by providing a third bool
argument to the directive.
@in('1', [1, 2], true)
This never gets rendered. Strings aren't integers.
@endif
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.