If you do this you get an error:
@if($foo)@if($bar)test@endif@endif
And if you do this, you get test >
test >
Try with a ternary operator, there is no whitespace control in Laravel
{{ $foo ? ($bar ? 'test' : '') : ''}}