按照教程上的指示这么做着(http://v4.golaravel.com/docs/4.2/templates#blade-templating)
就是在系统自动生成的HomeController含有如下代码:
protected $layout = 'layouts.master';
/**
* Setup the layout used by the controller.
*
* @
return void
*/
protected function setupLayout()
{
if ( ! is_null($this->layout))
{
$this->layout = View::make($this->layout);
}
}
public function showWelcome()
{
// echo $content = View::make('hello'); //一段html内容
$this->layout->title = '我是标题';
$this->layout->content = View::make('hello');
// echo $this->layout->content; //一段html代码
}
----------
这里说明下hello.php模板中的内容,就是一段已经写好了的bootstrap前端框架代码,单独在showWelcome()方法中使用View::make('hello')方法获取后echo出有了这个模板。
在echo $this->layout->content时也有内容!
在blade中,我写@
yield('content','暂时没有内容...') 却每次都显示“暂时没有内容”。悲剧啊~~~~~~~~
------------------
刚刚在layout中进行了如下代码测试:
<div class="container">
<?php echo $content; //出现了html内容 ?>
@
yield('content')<!--无内容-->
</div>
为什么@
yield不显示内容?