Specifically, I want to be able to achieve the following lines of code in a blade.php file, instead of by using twig's templating.
Samples from Twig's documentation
{% include (['A.html', 'B.html']) ignore missing %}
{% include (['A.html', 'B.html']) ignore missing with {'foo': 'bar'} %}
{% include (['A.html', 'B.html']) ignore missing only %}
I know what I need will look something like this
@include( (['A.html', 'B.html']) --ignore missing with-- {'foo': 'bar'})
Any tips would be greatly appreciated.
In PHP this is the difference between include
and require
. require
will generate a fatal error if the file doesn't exist, include
will generate a warning and continue. You can suppress the warning with @
.
@include 'filename.php'
You can use @includeIf
in blade to include a file that may or may not exist:
@includeIf('view.name', ['foo' => 'bar'])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.