laravel blade模板引擎内容显示在html标签之外

时间:2014-09-07 12:47:22

标签: templates laravel view

我对laravel框架工作很新,我正在使用laravel 4.2,现在我的刀片模板引擎有问题。     在我的laravel管理面板中用户登录后,将显示一个仪表板页面。这个页面工作正常。这个页面由master.header.php(这是我的标题)和仪表板页面组成,这是我的左侧菜单。

刀片代码如下

<pre>
   below is my dashboard page code 
   @extends('includes.header')
   @section('head')

   @parent   
   <title>DashBoard</title>
   @stop

   @section('content')
   LEFT MENU COMES HERE 
   @stop
</pre>
   <pre>Now in my left menu different links are there. 

所以我想在每个链接页面中包含header.blade.php和dashboard.blade.php。

左侧菜单页面代码如下

<pre>
    page name is : Employee.blade.php
    @extends('usercp.dashboard')
    @section('head')
    @stop
    @section('content')
    hi this is my one of left menu section
</pre>
    **OUT PUT**
<pre>

But when i click on the left menu link the content is displaying (hi this is my one of left menu section) at the header. 
When i see the source of Employee.blade.php the left menu is out side </html> tag.
Not in body tag. 
Can any one please help me in this regard.

</pre> 

1 个答案:

答案 0 :(得分:0)

关于代码的一些想法:

  • 在左侧菜单页面中,@section('content')未关闭,请添加 @stop

  • @extends命令必须是刀片中的第一行 模板,之前没有html / whitespace。

  • 如果要包含其他刀片模板(例如标题),请使用 @include('partials.header')。通过扩展另一个模板,您可以 覆盖父模板的部分,而不是 你想要的是什么,我猜。