سؤال

I am new to Laravel4, so I was learning from the documentation. It seems everything is all correct, but the extends method literally displays its code on my web browser. I don't know hwy..

This is the layout file (base.blade.php under layouts directory)

<!-- app/views/layouts/base.blade.php -->
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>
    <!-- You can provide some default content -->
    @section('head')
        <link rel="stylesheet" href="style.css" />
    @show
</head>
<body>
    @yield('body')
</body>
</html>

and home.blade.php.

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

@extends('layouts.base')

@section('body')
    <h1>Hurray!</h1>
    <p>We have a template!</p>
@stop

and my routing configuration is like below..

Route::get('/', 
  function()
  {
    return View::make('home');
  }
);

Now when you access to the URL, it displays just a string!

@extends('layouts.base')

I have been googling for a hour or so! still could not fix it... What's wrong with them? :(

  • I checked common mistakes below
  • possible type
  • incorrect path
  • incorrect method name
  • missing appending 'blade' on the file name

BUT STILL CAN'T FIND THE PROBLEM. :(

هل كانت مفيدة؟

المحلول

There shouldn't be any space in the template above @extends at all no comments or whitespace

نصائح أخرى

Remove <!-- app/views/home.blade.php --> from home.blade.php

home.blade.php

@extends('layouts.base')

@section('body')
    <h1>Hurray!</h1>
    <p>We have a template!</p>
@stop

Possibilities are that you have printed @extends('layouts.base') twice in the page. Please have a look.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top