Please excuse me if this is a very silly question (I am relatively new to web dev.)
I am trying to pass objects from backend (NodeJS) to frontend (EJS). The object itself is being passed but the formatting is not kept.
The object in NodeJS:
console.log(project.output)
Output:
866-981-4022
639-714-6905
184.118.7634
232-097-6927
(513) 480-5802
However when I do it in HTML/EJS:
<div> <%= detail.output %> </div>
It renders like this:
866-981-4022 639-714-6905 184.118.7634 232-097-6927 (513) 480-5802
How can I fix this? I want it to print/render like it does in NodeJS
CodePudding user response:
You can add the style white-space: pre;
to the div so the new lines are rendered as is.
<div style="white-space: pre;"> <%= detail.output %> </div>
<div style="white-space: pre;">866-981-4022
639-714-6905
184.118.7634
232-097-6927
(513) 480-5802</div>