vendredi 4 mars 2016

How to extend multiple templates in Blade (Laravel 5)?

I have the following files:

foo.blade.php

<html>
   <head>
   </head>
   <body>
      <h1>Foo Template</h1>
      @yield('content')
   </body>
</html>

bar.blade.php

<h2>Bar Template</h2>
<div class="bar-content">
@yield('bar-content')
</div>

I want to create another file that is able to extend both the above templates. e.g something like this:

@extends('foo')
@section('content')
     <p>Hello World</p>
     @extends('bar')
     @section('bar-content')
          <p>This is in div.bar-content</p>
     @endsection
@endsection

To give:

<html>
   <head>
   </head>
   <body>
      <h1>Foo Template</h1>
      <p>Hello World</p>
      <h2>Bar Template</h2>
      <div class="bar-content">
          <p>This is in div.bar-content</p>
      </div>
   </body>
</html>

How can I do this?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1SnPyi5
via IFTTT

Aucun commentaire:

Enregistrer un commentaire