I created such a field in my Laravel app.blade.php file.
<h1>@yield('heading')</h1>
I use this in my about.blade.php file as follows. (phpstorm default spacings)
@section('heading')
TEST HEADING
@endsection
And I get an output like this. There’s a lot of space and slack. If I write them side by side, I get a result like this;
<h1> TEST HEADING
</h1>
or such a result if i write no-space
TEST HEADING@endsection
What solution can be produced for this to be gapless and smooth?
3
Answers
I guess I should use tags in about.blade.php file.
It seems to be resolved when I do this.
You could write strings in this format:
You could find more details here: https://laravel.com/docs/10.x/blade#displaying-data
To ensure that there are no extra spaces or gaps around your heading when using the
@yield
and@section
directives in Laravel’s Blade templates, you can use the@php
directive to write the heading without any extra whitespace or line breaks.Here’s an example of how you can modify your code to achieve a gapless and smooth heading:
In app.blade.php:
In about.blade.php:
By using the
@php
directive, you can write the heading directly without any extra spaces or line breaks. This will ensure that the output is gapless and smooth.Alternatively, if you prefer to use Blade syntax instead of the
@php
directive, you can use the{{ }}
tags to output the heading without any spaces:In about.blade.php:
Both of these approaches will produce the desired result with a gapless and smooth heading.