module Voltron::Svg::SassHelpers

Public Instance Methods

map_options(options={}) click to toggle source
# File lib/voltron/svg.rb, line 17
def map_options(options={})
  ::Sass::Util.map_hash(options) do |key, value|
    [key.to_sym, (value.respond_to?(:representation) ? value.representation : (value.respond_to?(:value) ? value.value : value))]
  end
end
svg_icon(source, options={}) click to toggle source
# File lib/voltron/svg.rb, line 11
def svg_icon(source, options={})
  tag = Voltron::Svg::Tag.new(source.value, { extension: :svg }.merge(map_options(options)))

  ::Sass::Script::String.new "url(\"#{tag.image_path}\");\nbackground-image: url(\"#{tag.svg_path}\"), linear-gradient(transparent, transparent);\nbackground-size: #{tag.width}px #{tag.height}px"
end