Laravel Blade without extra whitespace?

前端 未结 5 1166
难免孤独
难免孤独 2021-01-04 03:23

If you do this you get an error:

@if($foo)@if($bar)test@endif@endif

And if you do this, you get

test

5条回答
  •  北荒
    北荒 (楼主)
    2021-01-04 04:03

    Try with a ternary operator, there is no whitespace control in Laravel

    {{ $foo ? ($bar ? 'test' : '') : ''}}

提交回复
热议问题