Laravel模板引擎分号结束bug?

时间:2014-02-06 15:44:10

标签: php html html5 laravel-4 blade

我正在使用最新版本的Laravel 4和模板引擎。

我突然在每个页面的代码中都看到了这个。

"         ";</body></html>

这怎么可能?

这是我的布局文件:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>mytitle</title>
    <!-- Bootstrap core CSS 
    <link href="{{asset('css/bootstrap.css')}}" rel="stylesheet">-->
    <!-- Custom styles for this template -->
    <link rel="stylesheet/less" type="text/css" href="{{asset('less/all.less')}}" />
    <script src="{{asset('js/less-1.6.2.min.js')}}"></script>

    <link href="{{asset('css/sticky-footer-navbar.css')}}" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy this line! -->
    <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    @yield('page_css')
  </head>
  <body>
    <!-- Wrap all page content here -->
    <div id="wrap">
      @include('layouts.navigation')
      @yield('content')
    </div><!-- Wrap End -->
      @include('layouts.footer')
      <!-- Bootstrap core JavaScript
      ================================================== -->
      <!-- Placed at the end of the document so the pages load faster -->
      <script src="{{asset('js/jquery-1.11.0.min.js')}}"></script>
      <script src="{{asset('js/bootstrap.min.js')}}"></script>
      @yield('page_js')
    </body>
  </html>

未使用Altough page_js

它总是附加这个&#34;&#34;和分号。

有些页面也显示了这个

 <script src="http://localhost:8000/js/jquery-1.11.0.min.js"></script>
 <script src="http://localhost:8000/js/bootstrap.min.js"></script>
 <script src="http://localhost:8000/js/holder.js"></script>
<script>
$( document ).ready(function() {
});
</script>
    </body>
  </html>;

感谢您的帮助!

导航布局:

<div class="navbar navbar-default navbar-fixed-top" role="navigation">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
      <span class="sr-only">Toggle navigation</span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#">Test</a>
    </div>
    <div class="collapse navbar-collapse">
      <ul class="nav navbar-nav">
         <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown">Outfits <b class="caret"></b></a>
          <ul class="dropdown-menu">
            <li><a href="#">Top Outfits</a></li>
            <li><a href="#">Neuste Outfits</a></li>
            <li class="divider"></li>
            <li class="dropdown-header">Meine</li>
            <li><a href="#">Outfits</a></li>
            <li><a href="#">Favoriten</a></li>
          </ul>
        </li>
        <li><a href="#about">Test</a></li>
        <li><a href="#contact">Test</a></li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown">Test <b class="caret"></b></a>
          <ul class="dropdown-menu">
            <li><a href="#">Action</a></li>
            <li><a href="#">Another action</a></li>
            <li><a href="#">Something else here</a></li>
            <li class="divider"></li>
            <li class="dropdown-header">Nav header</li>
            <li><a href="#">Separated link</a></li>
            <li><a href="#">One more separated link</a></li>
          </ul>
        </li>
      </ul>
      <!-- Search Bar -->
      <form class="navbar-form navbar-left" role="search">
        <div class="form-group">
          <input type="text" class="form-control" placeholder="Suchbegriff" style="width:300px">
        </div>
      </form>
      <!-- Right Nav -->
      <ul class="nav navbar-nav navbar-right">
         <li><a href="#">Test</a></li>
        </ul>
          </div><!--/.nav-collapse -->
        </div>
      </div>

页脚布局:

<div id="footer">
    <div class="container">
        <p class="text-muted">Place sticky footer content here.</p>
    </div>
</div>

2 个答案:

答案 0 :(得分:9)

在模板中的某个位置,您可以在blade命令后使用分号,例如: @include('scripts');

你应该有类似的东西 @include('scripts')

答案 1 :(得分:0)

首先,我不确定,但您可以参考Laravel Doc网站:http://laravel.com/docs/templates

... 有时,例如当您不确定是否已定义节时,您可能希望将默认值传递给@yield指令。您可以将默认值作为第二个参数传递:

@yield('section', 'Default Content');

对于您的代码,请尝试以下操作:

@yield('page_js', '');