-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@include adding extra space/line break to content #27996
Comments
I just updated to Laravel 5.8.8 and this issue does not appear to be resolved. |
I'm getting the same. Here are some copy-and-paste steps to reproduce: composer create-project --prefer-dist laravel/laravel=5.8.3 issue-27996
echo -n "<div>@include('partial')</div>" > issue-27996/resources/views/parent.blade.php
echo -n "contents" > issue-27996/resources/views/partial.blade.php
echo "Artisan::command('issue-27996', function () {
\$this->comment(view('parent'));
});" >> issue-27996/routes/console.php
php issue-27996/artisan issue-27996 Expected vs Actual output: - <div>contents</div>
+ <div>contents
+ </div>
|
Okay, re-opening. |
Ping @bzixilu. Do you maybe have an idea if this is related to the changes you made? |
It appears they may be related. The cached view code for <div><?php echo $__env->make('partial', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?></div>
<?php /* /path/to/issue-27996/resources/views/parent.blade.php */ ?> The cached view code for contents
<?php /* /path/to/issue-27996/resources/views/partial.blade.php */ ?> So when |
A fix may be to leave out the diff --git a/src/Illuminate/View/Compilers/BladeCompiler.php b/src/Illuminate/View/Compilers/BladeCompiler.php
index 0f084b06f..c5a51c36f 100644
--- a/src/Illuminate/View/Compilers/BladeCompiler.php
+++ b/src/Illuminate/View/Compilers/BladeCompiler.php
@@ -123,7 +123,7 @@ class BladeCompiler extends Compiler implements CompilerInterface
);
if (! empty($this->getPath())) {
- $contents .= "\n<?php /* {$this->getPath()} */ ?>";
+ $contents .= "<?php /* {$this->getPath()} */ ?>";
}
$this->files->put(
|
@fitztrev it's the base of the whole reason why the feature was added: so the path line would exist at the very last line so PHPStorm could pick it up. |
Ok, I don't know the inner workings of PHPStorm. But maybe they would be able to parse it out when it's not on its own line. But now that you mention that, I'm curious why this was added. #27963 (comment) Maybe this should belong in a package too. |
@fitztrev touché and you make an excellent point here. Ultimately this wasn't my call though for this feature. And I do believe that the impact of this particularly feature (the path in the view) is worth adding because it empowers such a useful debugging feature in PHPStorm. However, I fully agree that we should look at how we can look at a way to keep the feature while solving this bug. |
Is this only a problem when you use an include between html tags? Or also in other ways/usages? |
👍 We'll wait to see what @bzixilu says, if there's another way PHPStorm could parse it.
Other ways/usages too. A blade |
This was touted online by JetBrains, Taylor, Laravel News, etc. Though not specifically mentioned, it seems like it would work out-of-the-box. So including it in the core makes sense. I think we should keep trying to make this work without going the third-party route. |
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. |
replace exact "\n"
fix possible undefined offset problem
incorrect code style fix
Closing this because we've decided to revert the feature for now. Please see #28099 (comment) for more info. |
This re-adds the functionality that was added in laravel/framework#27544 and laravel/framework#27976 and removed again in laravel/framework@33ce7bb. The main difference with this approach is that it takes into account the issue from laravel/framework#27996. By not introducing a newline it doesn't changes anything to the rendered view itself. The path is now applied as the final piece of code. This doesn't allows IDE's to rely on it being the last line though. Instead we use /**PATH and ENDPATH**/ to make sure we have an easy way for the IDE to pick up the path it needs.
This re-adds the functionality that was added in laravel/framework#27544 and laravel/framework#27976 and removed again in laravel/framework@33ce7bb. The main difference with this approach is that it takes into account the issue from laravel/framework#27996. By not introducing a newline it doesn't changes anything to the rendered view itself. The path is now applied as the final piece of code. This doesn't allows IDE's to rely on it being the last line though. Instead we use /**PATH and ENDPATH**/ to make sure we have an easy way for the IDE to pick up the path it needs.
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
expected html output:
actual html output:
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.
The text was updated successfully, but these errors were encountered: