Sha256: e317ed94a5f82260362d72b5c65dd89551ee9f9022779f09da311facaa223b88
Contents?: true
Size: 465 Bytes
Versions: 8
Compression:
Stored size: 465 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
8 entries across 8 versions & 1 rubygems