I have a string returned to one of my views, like this:
$text = \'Lorem ipsum dolor
There is another way. If object purpose is to render html you can implement \Illuminate\Contracts\Support\Htmlable
contract that has toHtml()
method.
Then you can render that object from blade like this: {{ $someObject }}
(note, no need for {!! !!}
syntax).
Also if you want to return html property and you know it will be html, use \Illuminate\Support\HtmlString
class like this:
public function getProductDescription()
{
return new HtmlString($this->description);
}
and then use it like {{ $product->getProductDescription() }}
.
Of course be responsible when directly rendering raw html on page.