Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在制作一个相当基本的 rails 应用程序,我想知道从文本字段中删除不需要的 html 的最佳方法是什么(基本上,我希望保留的只是链接,并且不超过 2 个换行符)。
目前,我正在剥离所有 html 并使用 simpleformat,因为它的开销似乎比使用 RDiscount 和 Markdown/Textile 少,但这并不是一个理想的解决方案。
应该是sanitize帮手吧。
sanitize
模块 ActionView::Helpers::SanitizeHelper
另一种选择是 Sanitize gem。
http://wonko.com/post/sanitize