I have a string that can have a carriage return or a new line, in ruby this is resolved like this:
puts “hola \n mundo”
in rails it is solved like this
<%= “hola <br> mundo”.html_safe %>
but the variable comes to me in this format
<%= “hola \n mundo”.html_safe %>
and it doesn't show the new line, I solved it with this code:
<%= “hola \n mundo”.gsub("\n","<br>").html_safe %>
but the client doesn't want me to modify the content of the variable, not even to display it. what do you suggest i can do?
Your options are more on the html/css side.
The first and simplest option is that you use
<pre>
The second is that you use the style
white-space: pre
In general, the second option is more recommended, since it is much more versatile regarding the design that the information you show will have.