al3gom3z al3gom3z - 5 days ago 6
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
and
home.blade.php
inside
views.admin
directory.

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

<!-- home.blade.php -->
@extends('admin.master')


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

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


Any ideas of what is happening?

Thanks.

Answer

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.

Comments