我正在尝试解码一些HTML实体,例如'&lt;'变为'<'。
'&lt;'
'<'
我有一个古老的宝石(html_helpers),但它似乎已经被抛弃了两次。
有什么建议吗?我将需要在模型中使用它。
HTMLEntities可以做到:
: jmglov@laurana; sudo gem install htmlentities Successfully 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!"