0
我試圖在模板(master.blade.php)中包含模板(widget.blade.php),如下所示。兩個模板都使用名爲'content'的部分,但部件輸出使用來自主部件的內容而不是部件內容。模板內部的laravel模板
master.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
<title>
@section('title')
@show
</title>
</head>
<body>
<div>
@section('content')
@show
</div>
<div>
@section('sidebar')
@show
</div>
</body>
</html>
widget.blade.php
<div class="widget">
@section('content')
@show
</div>
index.blade.php
@extends('master')
@section('content')
Main Content
@stop
@section('sidebar')
@include('mywidget')
@stop
mywidget.blade.php
@extends('widget')
@section('content')
My Widget Content
@stop
最終結果
Main Content
Main Content
任何想法如何解決這個衝突?
怎麼樣重命名爲 'widget.content'? –
好主意,但是當添加多個@include('mywidget')時,覆蓋會再次發生,並且會多次看到第一個mywidget內容。 – Abbas