framework: @include adding extra space/line break to content
- Laravel Version: 5.8.7
- PHP Version: 7.2.5, 7.3.3
- Database Driver & Version:
Description:
Blade @includes are appending extra white space to the end
Steps To Reproduce:
test/include.blade.php
this is only a test
parent.blade.php
<div>@include('test.include')</div>
expected html output:
<div>this is only a test</div>
actual html output:
<div>this is only a test
</div>
In most circumstances, this isn’t really an issue, but in cases where you need to prevent white-space between html elements, it becomes an issue as the extra whitespace creates a gap between them.
In Laravel 5.7.x, the same code returned the expected behavior. Potentially even within an earlier version of 5.8, but I’m not sure.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15 (14 by maintainers)
Commits related to this issue
- #27996 @include adding extra space/line break to content — committed to bzixilu/framework by bzixilu 5 years ago
- #27996 @include adding extra space/line break to content replace exact "\n" — committed to bzixilu/framework by bzixilu 5 years ago
- #27996 @include adding extra space/line break to content fix possible undefined offset problem — committed to bzixilu/framework by bzixilu 5 years ago
- @include adding extra space/line break to content #27996 code style fix — committed to bzixilu/framework by bzixilu 5 years ago
- @include adding extra space/line break to content #27996 incorrect code style fix — committed to bzixilu/framework by bzixilu 5 years ago
- Add view path to end of compiled blade view This re-adds the functionality that was added in https://github.com/laravel/framework/pull/27544 and https://github.com/laravel/framework/pull/27976 and re... — committed to illuminate/view by driesvints 5 years ago
- Add view path to end of compiled blade view This re-adds the functionality that was added in https://github.com/laravel/framework/pull/27544 and https://github.com/laravel/framework/pull/27976 and re... — committed to illuminate/view by driesvints 5 years ago
Hi all, sorry for one more breakage of Blade usage scenario. I’ll start an investigation today and will do my best to come back soon with the possible solution.
Heya, I think this might be related to https://github.com/laravel/framework/pull/27544 which adds an extra linebreak at the end. This got fixed in https://github.com/laravel/framework/pull/27976 which will be released tomorrow. Feel free to report back if tomorrow’s release doesn’t fixes your problem.
👍 We’ll wait to see what @bzixilu says, if there’s another way PHPStorm could parse it.
Other ways/usages too. A blade
@include()
is always appending a newline when rendered. The surrounding<div>
tag was only used in the example to better illustrate the problem.