If you do this you get an error:
@if($foo)@if($bar)test@endif@endif
And if you do this, you get test >
test >
You can add {{""}} in between the code you want to close or connect without space.
{{""}}
@if($foo)@if($bar)test@endif{{""}}@endif