Support the ongoing development of Laravel.io →
posted 9 years ago
Blade
Last updated 2 years ago.
0

I use {{ nl2br(e($text)) }}

0

I have a similar issue - I have a textarea that gets saved to the db. When I display it, I lose the line breaks. if I wrap with nl2br the break tag is displayed as text rather than rendered as a line break so my output looks like this:

this is some text<br />this is the next line

checking the source and the break tag is served as:

@lt;br&nbsp;/&gt;

in my blade file I tried the following:

{{ $words }}  //No line breaks displayed
{{ nl2br($words )) }} // result as described above
{{ nl2br(e($words)) }} // result as described above

Any clues as to why this may be happenning?

0

It should be

{!! nl2br(e($words)) !!}
0

if you do so, be carreful with $words containing JS or so

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Victor victor Joined 18 Nov 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.