TIP 17 / 20

Cleanup Loops.

Did you know the Blade @each directive can help cleanup loops in your templates?

blade
// Current approach:
@foreach($item in $items)
    <div>
        <p>Name: {{ $item->name }}
        <p>Price: {{ $item->price }}
    </div>
@endforeach

// Improved approach with the HTML extracted into a partial:
@each('partials.item', $items, 'item')