-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pre-populating textarea adds extra newline characters #68
Comments
I made a little template for Ruby Haml: - message = "hoho\n\rHehe"
- id = 12
%textarea.msgpost{:id => "post_#{id}", :name => 'message', :placeholder => 'Add a comment, image or pdf...', :maxlength => '2000' }= message
%textarea.msgpost{:id => "post_#{id}", :name => 'message', :placeholder => 'Add a comment, image or pdf...', :maxlength => '2000' }
= message and the output is <textarea class='msgpost' id='post_12' maxlength='2000' name='message' placeholder='Add a comment, image or pdf...'>hoho
Hehe</textarea>
<textarea class='msgpost' id='post_12' maxlength='2000' name='message' placeholder='Add a comment, image or pdf...'>hoho
Hehe</textarea> So Ruby Haml does only whitespace preservation when adding the content directly to the textarea and not as child. Haml Coffee does the same: - message = "hoho\n\rHehe"
- id = 12
%textarea.msgpost{:id => "post_#{id}", :name => 'message', :placeholder => 'Add a comment, image or pdf...', :maxlength => '2000' }= message
%textarea.msgpost{:id => "post_#{id}", :name => 'message', :placeholder => 'Add a comment, image or pdf...', :maxlength => '2000' }
= message and the output is: <textarea class='msgpost' id='post_12' name='message' placeholder='Add a comment, image or pdf...' maxlength='2000'>hoho

Hehe</textarea>
<textarea class='msgpost' id='post_12' name='message' placeholder='Add a comment, image or pdf...' maxlength='2000'>hoho
Hehe</textarea> Again, whitespace preservation is only done in the first example, so far so good, but the difference is that Ruby Haml converts CRLF (\r\n) to CR (\n), which Haml-Coffee does not. So this is a bug! But the bug is only visible because I put the data directly within the template and with a real Backbone model the textarea preservation will not work because it's dynamic. In this case you anyway need to make use of %textarea.msgpost{:id => "post_#{id}", :name => 'message', :placeholder => 'Add a comment, image or pdf...', :maxlength => '2000' }~ message
%textarea.msgpost{:id => "post_#{id}", :name => 'message', :placeholder => 'Add a comment, image or pdf...', :maxlength => '2000' }
~ message otherwise the find a preserve helper will not be called. Bugs to be fixed:
Thanks a lot for reporting. |
Assuming that
@model.get("message")
is a string with newline characters\n\r
in itreturns a textarea with double the number of newline characters originally in the string.
However
does not insert extra newline characters.
Any ideas.
The text was updated successfully, but these errors were encountered: