Array.join(“\n”) not the way to join with a newline?

后端 未结 7 1536
遥遥无期
遥遥无期 2020-12-29 01:44

I have an array..

[1,2,3,4]

and I want a string containing all the elements separated by a newline..

1

2

3

4


        
相关标签:
7条回答
  • 2020-12-29 02:37

    You may not want to use html_safe, like ajay said, depending on context. Html safe can be a security issue. This depends on if the original input was actually html safe. HTML safe should not be called on input direct from a user and typically should be called before the view.

    https://bibwild.wordpress.com/2013/12/19/you-never-want-to-call-html_safe-in-a-rails-template/

    [edited in response to comment below]

    0 讨论(0)
提交回复
热议问题