我正在尝试解码一些 HTML 实体,例如'&lt;'成为'<'.
'&lt;'
'<'
我有一个旧的 gem ( 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!"