Last active
August 29, 2015 14:00
-
-
Save t-oginogin/11213134 to your computer and use it in GitHub Desktop.
Railsでタグをエスケープしつつ、改行を含む複数行のTextを表示したい ref: http://qiita.com/t_oginogin/items/0164ad76b753fdff9902
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <%= simple_format(text) %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <%= sanitize(simple_format(text), :tags => %w(p br)) %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def br(str) | |
| html_escape(str).gsub(/\r\n|\r|\n/, "<br />").html_safe | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| simple_format(h(text)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment