I have a $text
variable that holds some text and HTML code. I would like to render its HTML, but still make sure the rest of the string is escaped.
$text = 'Example text with image <img src"image_1.jpg">. More text...'
// This will render the HTML but will NOT escape the string
{!! $text !!}
// This will escape and display the variable as raw string, with no HTML rendering
{{ $text }}
In Laravel 5, is there a way to escape a string with Blade while allowing HTML?
I am not aware of such functionality in blade. You can not just allow specific HTML tags, because they may have unwanted stuff (like onload) inside them. Processing of string may be tricky. Have you considered markup language?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With