Php 拉威尔叶片直列截面

Php 拉威尔叶片直列截面,php,laravel,blade,laravel-blade,Php,Laravel,Blade,Laravel Blade,我需要在我的刀片模板中复制一段html,但它太小了,我不想创建新文件。我可以在我使用的同一个文件中创建一个节吗?例如: @section('small') <div>small piece of html</div> @endsection @include('small') <div>some html here</div> @include('small') @节(“小”) 一小段html @端部 @包括(‘小’) 这里有一些htm

我需要在我的刀片模板中复制一段html,但它太小了,我不想创建新文件。我可以在我使用的同一个文件中创建一个节吗?例如:

@section('small')
    <div>small piece of html</div>
@endsection

@include('small')
<div>some html here</div>
@include('small')
@节(“小”)
一小段html
@端部
@包括(‘小’)
这里有一些html
@包括(‘小’)
您需要与Laravel一起使用,并在example.blade.php中创建模板,在组件中设置变量,并在调用组件时将变量发送到组件,如下所示:

@component('alert', ['foo' => 'bar'])
    ...
@endcomponent
因此,它位于不同的文件中,但在将变量发送到组件时,它可能会很有效。

您需要与Laravel一起使用,并在example.blade.php中创建模板,在组件中设置变量,并在调用组件时将变量发送到组件,就像:

@component('alert', ['foo' => 'bar'])
    ...
@endcomponent

因此,它位于不同的文件中,但在将变量发送到组件时,它可能会很有效。

您是说重复@section吗?如果是,则使用另一个名称创建@yield,并在同一模板中调用这两个部分

第1页:

@yield('section1')
@yield('section2')
@section('section1')
    <div>small piece of html</div>
@endsection

@section('section2')
     <div>some html here</div>
@endsection
@stack('small')
@push('small')
    <div>small piece of html</div>
@endpush
@push('small')
     <div>some html here</div>
@endpush
第2页:

@yield('section1')
@yield('section2')
@section('section1')
    <div>small piece of html</div>
@endsection

@section('section2')
     <div>some html here</div>
@endsection
@stack('small')
@push('small')
    <div>small piece of html</div>
@endpush
@push('small')
     <div>some html here</div>
@endpush
@section('section1'))
一小段html
@端部
@节(“第2节”)
这里有一些html
@端部

你是说重复@section?如果是,则使用另一个名称创建@yield,并在同一模板中调用这两个部分

第1页:

@yield('section1')
@yield('section2')
@section('section1')
    <div>small piece of html</div>
@endsection

@section('section2')
     <div>some html here</div>
@endsection
@stack('small')
@push('small')
    <div>small piece of html</div>
@endpush
@push('small')
     <div>some html here</div>
@endpush
第2页:

@yield('section1')
@yield('section2')
@section('section1')
    <div>small piece of html</div>
@endsection

@section('section2')
     <div>some html here</div>
@endsection
@stack('small')
@push('small')
    <div>small piece of html</div>
@endpush
@push('small')
     <div>some html here</div>
@endpush
@section('section1'))
一小段html
@端部
@节(“第2节”)
这里有一些html
@端部

我认为你需要的是
@stack
@push
而不是
@section
假设你要在另一个文件中使用它

第1页:

@yield('section1')
@yield('section2')
@section('section1')
    <div>small piece of html</div>
@endsection

@section('section2')
     <div>some html here</div>
@endsection
@stack('small')
@push('small')
    <div>small piece of html</div>
@endpush
@push('small')
     <div>some html here</div>
@endpush
第2页:

@yield('section1')
@yield('section2')
@section('section1')
    <div>small piece of html</div>
@endsection

@section('section2')
     <div>some html here</div>
@endsection
@stack('small')
@push('small')
    <div>small piece of html</div>
@endpush
@push('small')
     <div>some html here</div>
@endpush
@push('small')
一小段html
@端推
@推(“小”)
这里有一些html
@端推

我认为你需要的是
@stack
@push
而不是
@section
假设你要在另一个文件中使用它

第1页:

@yield('section1')
@yield('section2')
@section('section1')
    <div>small piece of html</div>
@endsection

@section('section2')
     <div>some html here</div>
@endsection
@stack('small')
@push('small')
    <div>small piece of html</div>
@endpush
@push('small')
     <div>some html here</div>
@endpush
第2页:

@yield('section1')
@yield('section2')
@section('section1')
    <div>small piece of html</div>
@endsection

@section('section2')
     <div>some html here</div>
@endsection
@stack('small')
@push('small')
    <div>small piece of html</div>
@endpush
@push('small')
     <div>some html here</div>
@endpush
@push('small')
一小段html
@端推
@推(“小”)
这里有一些html
@端推

也许你想在这里做一个广告
@component('small')@endcomponent
我需要在使用它的同一个文件中定义它,你可能想在这里创建一个
@component('small')@endcomponent
我需要在使用它的同一个文件中定义它