如何使用空格设置文本格式?
例如,我在textarea写道:
This is first line
//i need this white space
//i need this white space
And this is second line
Simple_format不包含此空格,而使用simple_format,它看起来像这样:
This is first line
And this is second line
答案 0 :(得分:0)
使用linebreak \n
text = "This is first line\n \n And this is second line"
或者您可以使用
test = <<-EOF
This is first line
And this is second line
EOF
使用Google搜索时,您可以在Ruby中使用多行文字。
答案 1 :(得分:0)
我认为raw
可以实现这一目标。
<%= raw(@mytext) %>
答案 2 :(得分:0)
将您的输出放在<pre>
或<div style="white-space: pre-wrap;">
。
我认为这些日子有<pre-wrap>
,但这次我似乎无法谷歌。