How can I use strip_tags in regular Ruby code (non-rails)?

前端 未结 8 1453
广开言路
广开言路 2020-12-31 00:09

I need to turn HTML into plain text. There\'s a nice function that does that in ActionView\'s SanitizeHelper, but I have trouble understanding how I can reference it and use

8条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-31 00:17

    The question is quite old, but I had the same problem recently. I found a simple solution: gem sanitize. It's light, works fine and has additional options if you need them.

    Sanitize.clean("lol") #=> "lol"
    

提交回复
热议问题