Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Laravel 5.1 blade templates, how can I use @yield without the extra space added at the end?

I have a blade template master.blade that has the following code:

<title>@yield('meta-title')</title>

And then in any views that extend this template, the data can be passed in like this:

@section('meta-title')My Meta Title @stop

However, this ALWAYS adds a space at the end. If I remove the space in the code so it looks like the following, then it will not recognise the @stop and the page breaks:

@section('meta-title')My Meta Title@stop

Is there a way to achieve this functionality (dynamically inject content into the header without any spacing before or after) either using @yield or some other way?

Blade Template Docs

like image 648
Daniel Twigg Avatar asked Oct 26 '15 15:10

Daniel Twigg


1 Answers

Pass a second parameter to @section, like so: @section('meta-title', 'My Meta Title'), no need for @stop

It is indeed in the docs: http://laravel.com/docs/5.1/blade#template-inheritance

like image 112
veksen Avatar answered Oct 09 '22 07:10

veksen