Laravel Blade if statement
Today I noticed that PHPStorm 8 is not counting div's correctly if there is a if loop inside of it. Take a look at the code below
@section('slider')
<div >
<div >
<div id="slider">
<?php $i = 1; ?>
@foreach($sliders as $slider)
<div>
<img src="/images/slider/{{$slider->image}}" alt="WRR Motor">
@if($i % 2 == 0)
<div >
@else
<div >
@endif
<h2>{{$slider->title}}</h2>
</div>
</div>
<?php $i++; ?>
@endforeach
</div>
</div>
<div >
<img src="http://placehold.it/500x300&text=For Small Screens"/>
</div>
</div>
@stop
Storm is throwing an error that div is not closed
Please sign in to leave a comment.
As I can see the div is really not closed - 7 opening tags and 6 closing, so IDE is correct.
You have if/else statement which has 2 open div. Logic will execute only one of those two, so in fact you do not have 2 but 1. And that is the problem.