How can i convert/replace every newline to '
'?

前端 未结 5 1694
南笙
南笙 2021-01-21 05:55
set tabstop=4
set shiftwidth=4
set nu
set ai
syntax on
filetype plugin indent on

I tried this, content.gsub(\"\\r\\n\",\"
\")
bu

5条回答
  •  甜味超标
    2021-01-21 06:11

    With Ruby On Rails 4.0.1 comes the simple_format from TextHelper. It will handle more tags than the OP requested, but will filter malicious tags from the content (sanitize).

    simple_format(t.content)
    

    Reference : http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html

提交回复
热议问题