06.10.2016 Views

laravel-5

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Blade Templates 179<br />

1 @include('view.name', ['some' => 'data'])<br />

Note: You should avoid using the __DIR__ and __FILE__ constants in your Blade views,<br />

since they will refer to the location of the cached view.<br />

Rendering Views For Collections<br />

You may combine loops and includes into one line with Blade’s @each directive:<br />

1 @each('view.name', $jobs, 'job')<br />

The first argument is the view partial to render for each element in the array or collection. The<br />

second argument is the array or collection you wish to iterate over, while the third argument is the<br />

variable name that will be assigned to the current iteration within the view. So, for example, if you<br />

are iterating over an array of jobs, typically you will want to access each job as a job variable within<br />

your view partial. The key for the current iteration will be available as the key variable within your<br />

view partial.<br />

You may also pass a fourth argument to the @each directive. This argument determines the view<br />

that will be rendered if the given array is empty.<br />

1 @each('view.name', $jobs, 'job', 'view.empty')<br />

Comments<br />

Blade also allows you to define comments in your views. However, unlike HTML comments, Blade<br />

comments are not included in the HTML returned by your application:<br />

1 {{-- This comment will not be present in the rendered HTML --}}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!