al3gom3z al3gom3z - 10 months ago 97
PHP Question

Laravel Blade rendering <head> contents inside <body>

I need a little help here...

When I try to render a simple template in blade, I get a bad rendered html.

I have


<!-- master.blade.php -->
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8"/>
<title>Test Title</title>

<!-- home.blade.php -->

The rendered HTML when I call
return view("admin.home");
looks like this:

<html lang="en">
<meta charset="utf-8">
<title>Test Title</title>

Any ideas of what is happening?


Answer Source

Usually the case for the "&#65279;" character appearing is that it has been introduced by using a non UTF-8 encoded text editor or was introduced in a different way. My suggestion would be to use something like Sublime Text or Notepad++ to create fresh versions of each of these three documents. This usually happens because of a copy/paste without realizing it or using a text editor that has "extra formatting" that you cannot see (e.g. Word). The character is ZERO WIDTH NO-BREAK SPACE (you can see more information here). So, it's not a Laravel Blade issue, it's that extra whitespace-type characters are being introduced by whichever text editor you're using.