Sha256: 57faf432ca87e09047badc8eab1ba7ea0fa08df4c302e45b1329c73e3a1bdf07
Contents?: true
Size: 464 Bytes
Versions: 4
Compression:
Stored size: 464 Bytes
Contents
class ApplicationHelper def show_svg(attachment, options = {}) return if !attachment.content_type.include?('svg') attachment.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 options.each { |attr, value| svg[attr.to_s] = value } doc.to_html.html_safe end end end
Version data entries
4 entries across 4 versions & 1 rubygems