title: Passing array from view(Blade) to another view(Blade) in laravel
body: <p>I have master layout of laravel blade template <code>main.blade.php</code></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;title&gt;@yield('title','My Site')&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      @yield('container','Content area')
  
      {{ HTML::script('assets/js/jquery-1.9.0.js') }}
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I extended it for another view <code>index.blade.php</code></p>
  
  <pre><code>@extend('main')
  </code></pre>
  
  <p>I want to add javascript links to master layout(<code>main.blade.php</code>) if exists in child layout(<code>index.blade.php</code>)</p>
  
  <p>added code in <code>index.blade.php</code></p>
  
  <pre><code>$extraJs = array('plugins1.js','plugins2.js');
  
  @section('extraJs')
  {{ $extraJs }}
  @stop
  </code></pre>
  
  <p>So, How can I add javascript to master layout if exists in child blade? </p>
  
  <p>In php:</p>
  
  <pre><code>&lt;?php 
  if(isset($extraJs)): 
  foreach($extraJs as $js):
  ?&gt;
  &lt;script src="assets/js/&lt;?php echo $js ?&gt;" type="text/javascript" /&gt;
  &lt;?php endforeach; endif; ?&gt;
  </code></pre>