Class: ApplicationHelper
- Inherits:
-
Object
- Object
- ApplicationHelper
- Defined in:
- app/helpers/application_helper.rb
Instance Method Summary collapse
Instance Method Details
#show_svg(attachment, options = {}) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/helpers/application_helper.rb', line 2 def show_svg(, = {}) return if !.content_type.include?("svg") .open do |file| content = file.read doc = Nokogiri::HTML::DocumentFragment.parse content svg = doc.at_css "svg" # for security doc.search("script").each do |src| src.remove end .each { |attr, value| svg[attr.to_s] = value } doc.to_html.html_safe end end |