Laravel 4 Blade @include variable

Solution:1

Why would you pass it from the include to the calling template? If you need it in the calling template, create it there, then pass it into the included template like this:

@include('view.name', array('some'=>'data'))

Above code snippet from http://laravel.com/docs/templates

Solution:2

Unfortunately Laravel Blade engine doesn’t support what you expected!.But a little traditional way you can achieve this!

SOLUTION 1 – without Laravel Blade Engine

Step a:

from

file_include.blade.php

to

file_include.php

Step b:

main.blade.php

<?php 
     include('app/views/file_include.php')
?>
{{$myvar}}

SOLUTION 2 with Laravel Blade Engine

routes.php

$data = array(
'data1'         => "one",
'data2'         => "two",
);

View::share('data', $data); 

Access $data array from Any View like this

{{ $data['data1'] }}

Output

one