Skip to content

Instantly share code, notes, and snippets.

@t-oginogin
Last active August 29, 2015 14:00
Show Gist options
  • Select an option

  • Save t-oginogin/11213134 to your computer and use it in GitHub Desktop.

Select an option

Save t-oginogin/11213134 to your computer and use it in GitHub Desktop.
Railsでタグをエスケープしつつ、改行を含む複数行のTextを表示したい ref: http://qiita.com/t_oginogin/items/0164ad76b753fdff9902
<%= simple_format(text) %>
<%= sanitize(simple_format(text), :tags => %w(p br)) %>
def br(str)
html_escape(str).gsub(/\r\n|\r|\n/, "<br />").html_safe
end
simple_format(h(text))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment