5th Tue
HTMLエスケープして改行をbrに変換
CMSで改行入力したものを出力時に
として出力するヘルパタグ。
application_helper.rbに追加する用。
ruby>>
def hbr(str)
str = html_escape(str)
str.gsub(/\r\n|\r|\n/, "
")
end
<<ruby
VIEW側では<%=hbr textarea_value %>のように使う。
posted by
ysakaki on Tue 5 Aug 2008 at 15:11 with 0 comments