Laravel 顶部有注释的刀片模板不工作
文件:app/route.phpLaravel 顶部有注释的刀片模板不工作,laravel,laravel-4,blade,Laravel,Laravel 4,Blade,文件:app/route.php Route::get('/', function() { return View::make('home'); }); {{-- Blade comment. --}} @extends('layouts.base') @section('head') <link rel="stylesheet" href="second.css" /> @stop @section('body') <h1>Heading&
Route::get('/', function()
{
return View::make('home');
});
{{-- Blade comment. --}}
@extends('layouts.base')
@section('head')
<link rel="stylesheet" href="second.css" />
@stop
@section('body')
<h1>Heading</h1>
<p>Hello Home!</p>
@stop
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
@section('head')
<link rel="stylesheet" href="style.css" />
@show
</head>
<body>
@yield('body')
</body>
</html>
文件:app/views/home.blade.php
Route::get('/', function()
{
return View::make('home');
});
{{-- Blade comment. --}}
@extends('layouts.base')
@section('head')
<link rel="stylesheet" href="second.css" />
@stop
@section('body')
<h1>Heading</h1>
<p>Hello Home!</p>
@stop
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
@section('head')
<link rel="stylesheet" href="style.css" />
@show
</head>
<body>
@yield('body')
</body>
</html>
{{--Blade comment.-}
@扩展('layouts.base')
@第节(“标题”)
@停止
@第节(“正文”)
标题
你好,家
@停止
文件:app/views/layouts/base.blade.php
Route::get('/', function()
{
return View::make('home');
});
{{-- Blade comment. --}}
@extends('layouts.base')
@section('head')
<link rel="stylesheet" href="second.css" />
@stop
@section('body')
<h1>Heading</h1>
<p>Hello Home!</p>
@stop
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
@section('head')
<link rel="stylesheet" href="style.css" />
@show
</head>
<body>
@yield('body')
</body>
</html>
@第节(“标题”)
@展示
@屈服(‘体’)
当我访问laravel.localhost时/
它只是输出
@扩展('layouts.base')
但是,如果我删除
{{--Blade comment.-}
然后它就完美地工作了
我可以知道问题出在哪里吗?扩展刀片视图中的第一行必须是@extends指令。是的,这是开发人员的惯例。 查看在线
119
protected function compileExtends($value)
{
// By convention, Blade views using template inheritance must begin with the
// @extends expression, otherwise they will not be compiled with template
// inheritance. So, if they do not start with that we will just return.
if (strpos($value, '@extends') !== 0)
{
return $value;
}
这意味着我不能在文件顶部添加任何注释?在这种情况下,据我所知,您不能,@extends指令必须位于最顶部,然后您可以编写注释。