simple_format http://apidock.com/rails/v4.0.2/ActionView/Helpers/TextHelper/simple_formathttp://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.htmlmy_text = "Here is some basic text...\n...with a line break."simple_format(my_text)# => "Here is some basic text...\n
...with a line break."simple_format(my_text, {}, wrapper_tag: "div")# => "Here is some basic text...\n ...with a line break."more_text = "We want to put a paragraph...\n\n...right there."simple_format(more_text)# => "We want to put a paragraph...
\n\n...right there.
"simple_format("Look ma! A class!", class: 'description')# => "Look ma! A class!
"simple_format(" ")# => "Unblinkable.
"simple_format(" It's true.", {}, sanitize: false)# => " "一个\n被认为是换行其之后是 两个\n被认为是分段其之前是之后If you want to escape all content, you should invoke the h method before calling the text helper.simple_format h('Example')# => "
<a href=\"http://example.com/\">Example</a>
"