Laravel 8 template layout slots vs Laravel old sections, yields and extends?

Viewed 884

I'm starting a new project with Laravel 8 and I realised that there is two ways to extends a layout from a view, the first is with the "new" way, using:

  • New Parent Layout Design

{{-- any other *.blade.php file that wants to inherit base-view.blade.php view --}}
<x-base-view>
   {{-- $slot is this everything block --}}
</x-base-view>

While the base-view is the base-view.blade.php blade file that has something like:

{{-- views/base-view.blade.php --}}

<html>
   <body>
      <div class="content">
         {{ $slot }}
      </div>
   </body>
</html>

And we have this other way:

  • "Old" Parent Layout Design

The old way consists in using @extends(), @yield(), @section(), to extends, render a section and define a section respectively

My Question

my question is: which is the best option? I mean, what is the advantages of using the first and what is the advantages of using the second? And more importantly, what is the pitfalls of using the first or the second way?

0 Answers
Related