Sha256: 09799f3f7fdfff067a073080856916a3e9633b518805874ec25dda57a7940c14
Contents?: true
Size: 475 Bytes
Versions: 1
Compression:
Stored size: 475 Bytes
Contents
require 'action_view/helpers' require 'action_view/context' module InlineSvg module ActionView module Helpers def inline_svg(filename, options={}) file = File.read(Rails.root.join('app', 'assets', 'images', filename)) doc = Nokogiri::HTML::DocumentFragment.parse file svg = doc.at_css 'svg' if options[:class].present? svg['class'] = options[:class] end doc.to_html.html_safe end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
inline_svg-0.0.1 | lib/inline_svg/action_view/helpers.rb |