I have a button in my site where the text shall be on 2 lines. The text in the button is populated by translation feature trans() with the content provided by the language files.
Now I face the problem when I enter HTML, in this case <br>, in the language file, it will be escaped and not be parsed.
return [
'iamaclown' = 'I am a<br>clown',
//...
];
<button>{{ trans( 'messages.iamaclown' ) }}</button>
This gives me the output
I am a<br> clown
But I want
I am a
clown
Is there a way to accomplish that?
To display unescaped data, wrap the trans( 'messages.iamaclown' ) in
{!! trans( 'messages.iamaclown' ) !!}
By default, Blade {{ }} statements are automatically sent through PHP's htmlentities function to prevent XSS attacks.
If you do not want your data to be escaped, you may use the following syntax:
The name of the website is, {!! $websiteName!!}.
Note: Be very careful when echoing content that is supplied by users of your application. Always use the double curly brace syntax to escape any HTML entities in the content.
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