Hello,
I'm facing a problem with blade templating and my layouts.
Here's my layout (in app/views/layouts/test.php:
<div id="@yield('div-id')">
<p>@yield('content')</p>
</div>
Here's my view:
@extends('layouts.test')
@section('div-id')
test_id
@stop
@section('content')
@lang('texts.test')
@stop
And here's the result:
<div id=" test_id ">
<p> test </p>
</div>
As you can see, there are white spaces before and after each yielded text. It is causing issues as you can imagine (css and js related).
Is there any way to tell blade not to add those useless (to me, maybe they have a purpose) white spaces?
Thank you
I know this issue too. Try not to intend your section content and remove white-space at line endings.
@section('div-id')
test_id
@stop
@section('content')
@lang('texts.test')
@stop
Thank you for you quick answer, it works for the first white-space (not always though), but not for the second. I checked and I have no white-spaces or tabs at the end of my lines. If I remove the CR LF, it's not working at all (it appears there need to be a line break before the @stop command).
Result with your input is:
<div id="test_id ">
<p> test </p>
</div>
I don't know why it doesn't fix the first white-space of the 'content' section tho.
Another solution: totally forgot about this ^^
@section('title', 'value')
Result
<title>value</title>
Example: http://alexwenzel.de/2014/223/line-breaks-in-blade-sections-and-yields
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community