Reputation: 157
I've searched for this on internet alot, but wasnt able to find answers. I'm using Laravel 5 and I've little issue with blade templating as in my project I need sometime to do multiple extends and I need to pass all data from one layout to all master layouts "extends"
Nested page example :
@extends('layouts.full', ['var' => 'key'])
@section('page')
page content here
@stop
layouts/full.blade.php example
@extends('app', ['need to pass same data here too'])
@section('content')
@yield('page')
@stop
and app.blade.php is just main html stuff
And I wanted to ask is there possibility to pass same vars without setting global variable like?
@extends('layouts.full', $data = [])
Upvotes: 3
Views: 1919
Reputation: 316
to pass multiple variables, use an array:
@extends('layouts.full', [ 'data' => ['var' => 'key'] ])
as for multiple extensions, maybe just use include statements in layouts.full :
@include('header')
@section('content')
@yield('page')
@stop
@include('footer')
Upvotes: 0
Reputation: 227
I think this might help you : https://laravel.com/docs/5.2/blade#service-injection
Upvotes: 1