Skip to content

Commit 3ab5778

Browse files
committed
Add doc for includeWhen
1 parent 68048ae commit 3ab5778

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

blade.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,13 @@ Of course, if you attempt to `@include` a view which does not exist, Laravel wil
337337

338338
@includeIf('view.name', ['some' => 'data'])
339339

340+
If you want to `@include` a view that depends on a condition you can use `@includeWhen`:
341+
342+
@php
343+
$display = true;
344+
@endphp
345+
@includeWhen($display, 'view.name', ['some' => 'data'])
346+
340347
> {note} You should avoid using the `__DIR__` and `__FILE__` constants in your Blade views, since they will refer to the location of the cached, compiled view.
341348
342349
<a name="rendering-views-for-collections"></a>

0 commit comments

Comments
 (0)