dongliushui2001
2015-08-02 14:45 阅读 50
已采纳

Laravel刀片模板错误

I have this code:

in laravel/resources/views/users.blade.php

@extends('layouts.main')

@section('content')
<p>
    Here's your content
</p>
@stop

in laravel/resources/views/layouts/main.blade.php

<html>
  <head>
    {{-- Common Header Stuff Here --}}
  </head>
<body>
<div class="navigation">
  @section('navigation')
    <a href="/">Home</a>
    <a href="/contact">Contact</a>
  @show
</div>
<div class="container">
  @yield('content')
</div>

in routes.php

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

When i launch my site (localhost/laravel/public/users) It prints only:

@extends('layouts.main')

enter image description here

what's wrong here? I'm using laravel 5

Thanks in advance, i'm newbie with laravel

FIIIIIIIIXEEED

@extends can't be indented, you can't put anything before it even whitespace.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    douxi4287 douxi4287 2015-08-02 14:57

    I think in Laravel 5 you cannot use return View::make('users'); That's only for pure HTML content (already compiled). If you want to use blade templates, you should instead use :

    return view('users');
    
    点赞 评论 复制链接分享

相关推荐