My application is written in Go. A page of the application receives user data from an HTML text area which is saved to Google App Engine datastore as string data. Then, on another page of the application, it requires to display the data in the format that the user typed into the HTML text area or at least preserve the line breaks as the user hit enter key while typing the data into the HTML text field.
I tried to use <pre>
tag to display the preserved line breaks that user typed into the text field which worked fine. However, I found that there is a double tab
\t\t
inserted at the beginning of the string when using the <pre>
tag which I could remove the double tab by using Javascript.
My idea to keep the line breaks that users type into the text field is to use javascript replace function to replace all
,
and to
<br>
, however, it didn't work out. It seems like Go doesn't output the line breaks into the html source code. I am using "html/template" for safety reason but I didn't expect it to remove the
characters from its output entirely. And is there any suggestion on the strange double tab \t\t
at the beginning to the string?