jerome
jerome

Reputation: 715

Laravel Blade ( Displaying data as new line)

So i have a <textarea> in my form. User can either enter a new line or single line. So when the user views the text it will be showed like how he/she inputs it.

Form

<textarea name="jo_unit" class = 'form-control' required="required" cols = '4'></textarea>

Expected Output

TESTING 1
TESTING 2
TESTING 3

What i get

What i get

My code on displaying it

{{ nl2br(@$get['result'][0]->jo_unit_2) }}

Upvotes: 4

Views: 5345

Answers (2)

PiTheNumber
PiTheNumber

Reputation: 23542

Use

{!! nl2br(e(@$get['result'][0]->jo_unit_2)) !!}

{!! !!} creates an escaped output and allows HTML (and XSS attacks).

To make it secure again you also need to use e() see helpers documentation.

Upvotes: 3

Sohel0415
Sohel0415

Reputation: 9853

Security: This code allows XSS attacks and is not production ready.

use {!! !!}:

{!! nl2br(@$get['result'][0]->jo_unit_2) !!}

Upvotes: 6

Related Questions