使用空格的文本格式

时间:2013-12-04 10:45:19

标签: ruby-on-rails

如何使用空格设置文本格式?

例如,我在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

3 个答案:

答案 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>,但这次我似乎无法谷歌。