Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enter Character should print a new line in html

I am getting "First Line.↵Second Line↵" as a string in an api response.I want to take this and print in html web page like <span>{{apiText}}</span>. where apiText is a javascript variable whose value is "First Line.↵Second Line↵". But the text appears on one line only.How to I convert to a format where it prints a break.

like image 556
kautilya Avatar asked Oct 18 '22 15:10

kautilya


1 Answers

That cr character is \n.

You can replace those with <br> tag.

refinedText: Ember.computed('apiText', function(){
  return this.get('apiText').replace('\n', '<br>');
})

and in template :

{{{refinedText}}
like image 90
Ebrahim Pasbani Avatar answered Oct 21 '22 02:10

Ebrahim Pasbani