Reputation: 1021
I'm currently developing web application with Ruby on rails.
When I command
<h4>wow this is a good webpage <code>loving each other</code> good good</h3>
, "loving each other" part are highlighted ( And I meant it because I learned this code can work through getbootstrap! ) : "code" "code" <---- in Stackoverflow page code code command is working so I put this here intentionally in a wrong way.
I wanted to make a specific string data look like that. In the application, I get the string data from
<textarea class = "form-control" name="input"></textarea>
But when I displayed it in the html, <code>
part was not recognized as a sort of code but a just string. Partially it seems it does make sense but not fully understood. How can I turn this type of information into a formatted version ( meaning some part is highlighted! )
Second question is that, the string data got from <textarea>
has "entering actions" meaning, the user clicks the "enter" a couple of times. When I display this information (for instance, @a = User.information, <- where User.information has a couple of sentences that are equal to the information ), the enters don't appear and all sentences look messy :(
I think there is for sure a way to do it properly!!! Looking forward to hearing opinion from the experts!
Upvotes: 0
Views: 49
Reputation: 4012
While rendering you should do something like this:
"<h4>wow this is a good webpage <code>loving each other</code> good good</h3>".gsub('\n','<br/>).html_safe
Upvotes: 1