laravel blade include error - syntax error, unexpected

爷,独闯天下 提交于 2019-12-05 06:40:05
majidarif

the problem is in the file that is getting included.

First to check if the problem is really that, remove everything inside testfooter.blade.php then open the view from the browser. You'll notice that there is no error anymore.

Change your testfooter.blade.php to:

<div class="footer">2013-2014</div>

remove the @section("testfooter")...@show.

Example:

<!-- app/views/header.blade.php -->

<h1>When does the Narwhal bacon?</h1>

<!-- app/views/footer.blade.php -->

<small>Information provided based on research as of 3rd May '13.</small>

You include it like:

<!-- app/views/example.blade.php -->

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Narwhals</title>
</head>
<body>
    @include('header')
    <p>Why, the Narhwal surely bacons at midnight, my good sir!</p>
    @include('footer')
</body>
</html>

Check this to learn more on blade.


The problem seems to be something else, I would just like to share this, If it can help you:

I'm using Notepad++ as text-editor and for some strange reason it had decided to use "MAC format" as the End-Of-Line (EOL) format. Apparently the Blade framework can't cope with that. Use the conversion function (in notepad++ : Edit -> EOL Conversion) to convert to Windows Format and it will work just fine...

Arjen

You have this:

@section("testfooter")
    <div class="footer">2013-2014</div>
@show // <--

Change it to this:

@section("testfooter")
    <div class="footer">2013-2014</div>
@stop // <--

Usually Laravel gives a great hint to the problem. The problem might be in your CSS or JS include statements. First make sure you have turn on the debug mode of laravel. Here is how to do it.

  1. Config/app -> debug = true at line 16
  2. Refresh the page where the error is

I have intentionally leave out closing ')' of css file. The laravel FW showed where that error, and it will show you similar error.

Hope it help.

In my case the issue was an unterminated string in some PHP in a totally different part of the file than Laravel was complaining about. I eliminated it by removing everything in the file and adding the lines in again one by one.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!