如何在Ruby中編碼/解碼HTML實體?我試圖解碼一些HTML實體,如'&lt;'成為'<'。我有一個舊的寶石(html_helpers),但似乎已經放棄了兩次。有什么建議?我需要在模型中使用它。
3 回答

慕碼人8056858
TA貢獻1803條經驗 獲得超6個贊
HTMLEntities可以做到:
: jmglov@laurana; sudo gem install htmlentitiesSuccessfully installed htmlentities-4.2.4: jmglov@laurana; irb irb(main):001:0> require 'htmlentities'=> []irb(main):002:0> HTMLEntities.new.decode "¡I'm highly annoyed with character references!"=> "?I'm highly annoyed with character references!"
- 3 回答
- 0 關注
- 767 瀏覽
相關問題推薦
添加回答
舉報
0/150
提交
取消