Laravel Blade: new line adds space for the old echo

I have 2 fields - the country and the city, which I want to show as follows: Country, City (with one space after the decimal point). The only way I can do this is to put everything on one line:

<li>{{{ $obj->country }}}@if($obj->city){{{ ', '.$obj->city }}}@endif</li>

This is really funny.

Now let's say I want to make it readable:

<li>
    {{{ $obj->country }}}
    @if($edu->city)
        {{{ ', '.$obj->city }}}
    @endif
</li>

As soon as the second echo moves to a new line, the entire line is displayed with additional space after "Country": Country, City .

Super annoying. Does anyone know how to prevent this behavior?

+4
source share
2

<li>
    @if($edu->city)
        {{{ $obj->country.', '.$obj->city }}}  
    @else
        {{{ $obj->country }}}
    @endif
</li>

:)

+4

: . PHP- - if/else.

public function getCountryAndCityAttribute() {
  return $this->country . ($this->city ? $this->city : '');
}

, :

<li>{{{ $obj->country_and_city }}}</li>
+1

Source: https://habr.com/ru/post/1569786/


All Articles