Answer the question
In order to leave comments, you need to log in
Where do extra spaces come from before lines when rendering a multiline string in a textarea?
Good afternoon, I took Rails5 for a new project and immediately stumbled upon a problem.
In short, there is a model with a text string field that needs to be edited in the textbox. Form code:
.form
=form_for article do |f|
.form-group
=field_label f, :text, true
=f.text_area :text, class: %w(form-control), rows: 20, placeholder: t('placeholder.article_text')
<textarea><%= "a\nb\nc" %></textarea>
<p><%= "a\nb\nc" %></p>
one also pushes a bunch of spaces, just the browser trims them (visible in the developer console) Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question