Skip to content

Commit 4e3d5d5

Browse files
committed
Document @continue and @break blade directives
1 parent 9895254 commit 4e3d5d5

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

blade.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,26 @@ In addition to conditional statements, Blade provides simple directives for work
167167
<p>I'm looping forever.</p>
168168
@endwhile
169169

170+
When using loops you might need to end the loop or skip the current iteration:
171+
172+
@foreach ($users as $user)
173+
@if($user->type == 1)
174+
@continue
175+
@endif
176+
177+
<li>{{ $user->name }}</li>
178+
179+
@if($user->number == 5)
180+
@break
181+
@endif
182+
@endforeach
183+
184+
You may also include the condition with the directive declaration in one line:
185+
186+
@continue($user->type == 1)
187+
188+
@break($user->number == 5)
189+
170190
#### Including Sub-Views
171191

172192
Blade's `@include` directive, allows you to easily include a Blade view from within an existing view. All variables that are available to the parent view will be made available to the included view:

0 commit comments

Comments
 (0)