だから、私は自分のインデックスページを印刷するためのこの種のコードを持っています:
class PageController extends MediaController {
protected $layout = 'layouts.main';
public function index_page() {
$data = array();
$data['title'] = 'Dynamic Title';
$data['css_files'] = array(
array('media'=>'all', 'file'=>'file1'),
array('media'=>'all', 'file'=>'file2')
);
$this->layout->content = View::make('index', $data);
}
}
そして私のmain.blade.php:
<html>
<head>
<title>@yield('title')</title>
</head>
<body>
@yield('content')
@yield('css_files')
</body>
</html>
そして私のindex.blade.php:
@section('title', $title)
@section('css_files')
@foreach ($css_files as $css_file)
<p>File: {{ $css_file->file }}, Media: {{ $css_file->media }}</p>
@endforeach
@stop
@section('content')
<h1>Rendered Successfully!</h1>
@stop
タイトルは問題なくレンダリングされますが、css ファイルには次のように出力されます。
ファイル: {{ $css_file->file }}、メディア: {{ $css_file->media }}
ファイル: {{ $css_file->file }}、メディア: {{ $css_file->media }}
これの代わりに:
ファイル: file1、メディア: すべて
ファイル: file2、メディア: すべて
誰でも理由を説明できますか?助けてくれてありがとう、私はBladeが初めてです。
- 編集 -
私はすでに問題を解決しました.Blade構文構成をたまたま編集しました
vendor\laravel\framework\Illuminate\view\compilers\BladeCompiler.php
から
protected $contentTags = array('{{', '}}');
/**
* Array of opening and closing tags for escaped echos.
*
* @var array
*/
protected $escapedTags = array('{{{', '}}}');
に
protected $contentTags = array('{=', '=}');
/**
* Array of opening and closing tags for escaped echos.
*
* @var array
*/
protected $escapedTags = array('{={', '}=}');
したがって、{{ の代わりに {= を使用する必要がありました
これが将来誰かに役立つことを願っています。