Laravel 4 在Laravel4中创建可重复使用的刀片块
我想在laravel刀片模板中创建一个可重用的块 我在下面写伪代码,想知道如何实现这个范围Laravel 4 在Laravel4中创建可重复使用的刀片块,laravel-4,blade,Laravel 4,Blade,我想在laravel刀片模板中创建一个可重用的块 我在下面写伪代码,想知道如何实现这个范围 // app/views/layouts/code.blade.php // the block I want to reuse <pre> <code> // fill the content here </code> </pre> //app/views/myview.blade.php // myview.blad
// app/views/layouts/code.blade.php
// the block I want to reuse
<pre>
<code>
// fill the content here
</code>
</pre>
//app/views/myview.blade.php
// myview.blade.php
<?= View::make('partials.code', [
'code' => 'my dynamic code content'
]); ?>
最好在刀片模板中创建一个新的
View::make()
调用
// partials/code.blade.php
<pre>
<code>
{{ $code }}
</code>
</pre>
最好在刀片模板中创建一个新的
视图::make()
调用
// partials/code.blade.php
<pre>
<code>
{{ $code }}
</code>
</pre>
您也可以在模板中包含视图/块。以及传递变量
也可以在模板中包含视图/块。以及传递变量
我试过这个,但是@include一次只读一行:(谢谢帮助:))我试过这个,但是@include一次只读一行:(谢谢帮助:))
@extends('layouts.main') // set header, body, and footer block
@section ('content')
@include('layouts.code', ['code'=>'some code'])
@include('layouts.code', ['code'=>'some other code'])
@endsection
// layouts.code.blade.php
<code>
{{ $code }}
</code>