@extends('layout') laravel. Blade Template System seems like Not working

I tried to use the laravel's template system: blade but seems like not working when using the code below in the file users.blade.php :

@extends('layout')

@section('content') Users! @stop

and browser,

@extends('layout')


That should work if you have a template file at /app/views/layout.blade.php that contains

<p>Some content here</p>

@yield('content')

<p>Some additional content here</p>

Then in your /app/views/user.blade.php, the content

@extends('layout')

@section('content')

<p>This is the user content</p>

@stop

If you call return View::make('user') you should have the compiled content

<p>Some content here</p>

<p>This is the user content</p>

<p>Some additional content here</p>

I hope that helps clarify things for you. If not, can you provide your template file locations and the relevant content?


Just remove the extra space or anything before @extends('yourlayoutfile').

It should be the first thing to be rendered in the file.

I was facing the same problem and tried many things.Suddenly I found a single space at the starting of the file before @extends.

Removed the space and is working fine.

Thanks.

Format:

@extends('layouts.default')
 @section('content') 
.....
 @stop

---Edit----

If this didnt work then try :

Copy all the content in the file and then delete the file.

Create a new file and save it as filename.blade.php

Only after saving the file paste the content into the page. Save the changes and run it.

This works.

Thank you.


Where is your layout?

If its in app/views/layouts , then it should be

@extends('layouts.index')

(assuming the name is index.blade.php)

ex: @extends('layouts.foo') equals a file in app/views/layouts/ called either foo.blade.php or foo.php . (depending if you use blade)

链接地址: http://www.djcxy.com/p/18778.html

上一篇: 如何检测双重

下一篇: @extends('布局')laravel。 刀片模板系统似乎不起作用