why laravel blade @yield adds a new line (line break)
From Laravel 5 onwards, the solution I like most is:
@section('description', 'this is the contact page')
You can use {{trim(View::yieldContent('description'))}}
The explanation.
I had the same problem. I had a few modal windows on the page, that had a common layout but different bodies, titles and "id" attributes. So, "id" attribute should be yielded without any spaces around.
The @yield
statement compiles to echo $__env->yieldContent
call (BladeCompiler.php, compileYield method). $_env
here is an instance of \Illuminate\View\Factory
. So you can use {{trim(View::yieldContent('description'))}}
where View is a facade.