Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Break lines in blade translation files

Tags:

php

laravel

blade

In my view I have

<p>{{ trans('mission-vision-page.mission-description') }}</p>

I've put a block of text in my language file, but I want to maintain the new lines. I've tried:

1.

return ['mission-description' => 'line 1 <br /> line 2']

2.

return ['mission-description' => 'line 1 \n line 2']

3.

$newLine = '<br />';    
return ['mission-description' => 'line 1 ' . $newLine . ' line 2']

I know probably there's a better way to accomplish this, but in my en.php file can I add new lines?

like image 742
Jorge Anzola Avatar asked Jun 09 '16 13:06

Jorge Anzola


People also ask

How do you add a line break in laravel blade?

nl2br — Inserts HTML line breaks before all newlines in a string. Laravel helper provide many functionalities and you can use e Laravel helper function to purify your html before showing line breaks. You need to do the escaping first using e() and then after apply nl2br() function.

How do you make a new line in laravel?

You can try: {!! 'first line <br> second line' !!}


1 Answers

use {!! !!} instead of {{ }} and <br/> tag in you message

<p>{!! trans('mission-vision-page.mission-description') !!}</p>
like image 163
huuuk Avatar answered Sep 30 '22 06:09

huuuk