Add loop variable and dump directive; reorganize template v2 unit tests

This commit is contained in:
Kijin Sung 2023-10-17 20:12:22 +09:00
parent fe804163bf
commit a6afa3a61d
7 changed files with 394 additions and 41 deletions

View file

@ -0,0 +1,22 @@
@version(2)
@php
$foo = ['red', 'blue', 'yellow', 'black', 'white'];
$bar = ['dog', 'cat', 'rabbit', 'panda', 'otter'];
@endphp
<h1>Pets</h1>
<ul>
@foreach ($foo as $color)
@foreach ($bar as $animal)
<li>
<span>A {{ $color }} {{ $animal }}</span>
<span>current index {{ $loop->index }} of {{ $loop->count }}</span>
<span>parent index {{ $loop->parent->index }} of {{ $loop->parent->count }}</span>
<span>first: @dump($loop->first)</span>
<span>last: @dump($loop->last)</span>
</li>
@endforeach
@endforeach
</ul>