在刀片模板意外endforeach [英] unexpected endforeach in blade template
问题描述
在laravel的 laravel
中有一个刀片
模板,它显示一个标签视图。这些标签是不同的事件类型
,在标签中是每个类型的事件
。这个观点直到今天都运行良好。唯一改变的是我可以软删除 events
。
我得到的错误是如下所示:
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $' pre
$ b
这是模板的完整源代码:
$ $ $ $ $ $ $ $ $ $ @extends('master')
@section('title',' - Kalenderbeheer')
@section('head')
{{HTML: :脚本( '脚本/ LIB / dataTables.js'); }}
< script>
$(document。).ready(function(){
$(#EventTypeTabs)。tab();
$ b $(。eventtable)。dataTable({
分页:false,
info:false,
aoColumns:[
null,
null,
null,
{asSorting :[]}
]
});
$(。eventtable tr)。click(function(){
if($(this) .data(id))
location.href =/ kalender / admin /+ $(this).data(id);
})
});
< / script>
@stop
@section('body')
< div class =row>
< div class =col-md-6 col-md-offset-1>
< h1> Kalenderbeheer< / h1>
< / div>
< div class =col-md-4 rtl>
< a href =/ kalender / admin / nieuw> Nieuwe activiteit toevoegen< / a>
< / div>
< / div>
< div class =row>
< div class =col-md-10 col-md-offset-1>
< a href =#{{{$ et-> getFormattedName()}}}data-toggle =tab> {{{$ et-> name}}}一个>
< / li>
@endforeach
< / ul>
< div class =tab-content eventtypetabs>
@foreach($ eventtypes as $ et)
@if(count($ et-> events)> 0)
< table class =table table-striped eventtable>
< thead>
< tr>
< th>#< / th>
< th> Datum< / th>
Naam< th>
< th>< / th>
< / tr>
< / thead>
< tbody>
<?php $ c = 0; ?>
@foreach($ et->事件为$事件)
< tr data-id ={{$ event-> id}}>
< td> {{++ $ c}}< / td>
< td> {{preg_replace(/ \ {2}:\d {2}:\d {2} /,,$ event-> start)}}< ; / TD>
< td> {{{$ event-> name}}}< / td>
< td> X< / td>
< / tr>
@endforeach
< / tbody>
< / table>
@endif
< / div>
@endforeach
< / div>
< / div>
< / div>
@stop
错误出现在最后 @endforeach
。这是错误的截图:
<$ c 在@endifid ={{{$ et-> getFormattedName()}}}中激活$ c>< div class =tab-pane fade @if($ et-> id == 1)> ;
另外,最好使用三元运算符:
class =tab-pane fade {{$ et-> id == 1?'active in':''}}
I have a blade
template in laravel
in laravel that displays a tab view. The tabs are different eventtypes
and in the tabs are the events
per type. This view worked fine until today. The only thing that changed is that I made it possible to soft-delete events
.
The error I get is the following:
syntax error, unexpected 'endforeach' (T_ENDFOREACH)
This is the entire source code of the template:
@extends('master')
@section('title', '- Kalenderbeheer')
@section('head')
{{ HTML::script('Script/lib/dataTables.js'); }}
<script>
$(document).ready(function(){
$("#EventTypeTabs").tab();
$(".eventtable").dataTable({
paging: false,
info: false,
"aoColumns": [
null,
null,
null,
{ "asSorting": [] }
]
});
$(".eventtable tr").click(function(){
if ($(this).data("id"))
location.href = "/kalender/admin/" + $(this).data("id");
})
});
</script>
@stop
@section('body')
<div class="row">
<div class="col-md-6 col-md-offset-1">
<h1>Kalenderbeheer</h1>
</div>
<div class="col-md-4 rtl">
<a href="/kalender/admin/nieuw">Nieuwe activiteit toevoegen</a>
</div>
</div>
<div class="row">
<div class="col-md-10 col-md-offset-1">
<ul class="nav nav-tabs" style="margin-bottom: 15px;" id="EventTypeTabs">
@foreach ($eventtypes as $et)
<li @if($et->id == 1) class="active" @endif>
<a href="#{{{ $et->getFormattedName() }}}" data-toggle="tab">{{{ $et->name }}}</a>
</li>
@endforeach
</ul>
<div class="tab-content eventtypetabs">
@foreach ($eventtypes as $et)
<div class="tab-pane fade @if ($et->id == 1)active in@endif" id="{{{ $et->getFormattedName() }}}">
@if (count($et->events) > 0)
<table class="table table-striped eventtable">
<thead>
<tr>
<th>#</th>
<th>Datum</th>
<th>Naam</th>
<th></th>
</tr>
</thead>
<tbody>
<?php $c = 0; ?>
@foreach ($et->events as $event)
<tr data-id="{{ $event->id }}">
<td>{{ ++$c }}</td>
<td>{{ preg_replace("/\d{2}:\d{2}:\d{2}/", "", $event->start) }}</td>
<td>{{{ $event->name }}}</td>
<td>X</td>
</tr>
@endforeach
</tbody>
</table>
@endif
</div>
@endforeach
</div>
</div>
</div>
@stop
The error appears on the last @endforeach
. This is a screenshot of the error:
You just need to add a space before @endif (line 48)
<div class="tab-pane fade @if ($et->id == 1)active in @endif" id="{{{ $et->getFormattedName() }}}">
Also, it's better to use the ternary operator:
class="tab-pane fade {{ $et->id == 1 ? 'active in' :''}}"
这篇关于在刀片模板意外endforeach的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!