I have a large HTML string from WYSIWYG and you want to show truncates string of only text, html or html tags. Is there a way to do this built into the rails, or do I need gsub to get rid of all the html brackets?
thank
Rails already includes some powerful sanitation assistants .
string = '<span id="span_is"><br><br><u><i>Hi</i></u></span>' strip_tags(string)
, HTML, , , Nokogiri XPath, , HTML. , , .
, , HTML . - Loofah sanitize , Nokogiri HTML, , .
require 'sanitize' html = '<html><body>Jackdaws love my giant sphinx of quartz.</body></html>' puts Sanitize.clean(html) # >> Jackdaws love my giant sphinx of quartz.
, loofah , , , , - , , .
Source: https://habr.com/ru/post/1777129/More articles:Delete inserts of UITableViewStyleGrouped UITableView? - iphoneHow to stop (not kill) an action to run onRestart ()? - androidReading bytes from a Python string - pythonOpen Source Objective-C Syntax Highlighter? - objective-cКакое программное обеспечение полезно при разработке/планировании большого нового личного проекта? - c++Add derived field to Django admin change form - pythonIntel GMA 4500HD & vsync - c ++NoClassDefFoundError occurs at runtime when I use mutliple Java packages in one Android project - androidThe correct userdir.conf for this .htaccess is .htaccessVB 2010 "variable" is not declared. It may not be available due to its level of protection - variablesAll Articles