【问题标题】:laravel blade template engine content displayed outside end html taglaravel 刀片模板引擎内容显示在结束 html 标记之外
【发布时间】:2014-10-31 20:26:12
【问题描述】:

我对 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> 

【问题讨论】:

    标签: templates laravel view


    【解决方案1】:

    对您的代码的一些想法:

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

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

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

    【讨论】:

      猜你喜欢
      • 2016-11-05
      • 1970-01-01
      • 2016-06-26
      • 2013-02-21
      • 2014-02-07
      • 2017-04-18
      • 1970-01-01
      • 1970-01-01
      • 2015-01-21
      相关资源
      最近更新 更多