Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 在Rails中自动添加段落_Ruby On Rails_Ruby - Fatal编程技术网

Ruby on rails 在Rails中自动添加段落

Ruby on rails 在Rails中自动添加段落,ruby-on-rails,ruby,Ruby On Rails,Ruby,WordPress有一个函数,wpautop,它会自动将段落标记环绕在任何输入字符串周围 例如,用户输入: This is a paragraph. I start another paragraph here. I didn't put in paragraph tags. You'll have to figure it out, WordPress. 通过wpautop后,输出字符串为 <p>This is a paragraph.</p> <p>

WordPress有一个函数,
wpautop
,它会自动将段落
标记环绕在任何输入字符串周围

例如,用户输入:

This is a paragraph.

I start another paragraph here. I didn't put in paragraph tags.

You'll have to figure it out, WordPress.
通过
wpautop
后,输出字符串为

<p>This is a paragraph.</p>

<p>I start another paragraph here. I didn't put in paragraph tags.</p>

<p>You'll have to figure it out, WordPress.</p>
这是一段

我从这里开始另一段。我没有把段落标记放进去

你得想清楚,WordPress


Ruby on Rails中是否有类似的功能或插件?

ActionView::Helpers::TextHelper
中有
simple\u format
方法,用于翻译HTML段落中文本中的新行:

simple_format("Here is some basic text...\n...with a line break.")
# => "<p>Here is some basic text...\n<br />...with a line break.</p>"

simple_format("We want to put a paragraph...\n\n...right there.")
# => "<p>We want to put a paragraph...</p>\n\n<p>...right there.</p>"
simple\u格式(“这是一些基本文本…\n…带换行符。”)
#=>“这是一些基本的文本…\n
…带有换行符。

” 简单的格式(“我们想把一个段落放在那里…\n\n…就在那里。”) #=>“我们想把一个段落放在那里。

\n\n就在那里。


在中找到更多示例。

ActionView::Helpers::TextHelper
中有一个
simple\u format
方法,用于翻译HTML段落中文本中的新行:

simple_format("Here is some basic text...\n...with a line break.")
# => "<p>Here is some basic text...\n<br />...with a line break.</p>"

simple_format("We want to put a paragraph...\n\n...right there.")
# => "<p>We want to put a paragraph...</p>\n\n<p>...right there.</p>"
simple\u格式(“这是一些基本文本…\n…带换行符。”)
#=>“这是一些基本的文本…\n
…带有换行符。

” 简单的格式(“我们想把一个段落放在那里…\n\n…就在那里。”) #=>“我们想把一个段落放在那里。

\n\n就在那里。


请在中找到更多示例。

为什么否决?这个答案没有错。我也不同意否决票,答案是正确的。为什么否决票?这个答案没有错。我也不同意反对票,答案是正确的