Last active
May 4, 2018 08:17
-
-
Save Kolenov/a59a581b0f9e6306e237dc80549902c4 to your computer and use it in GitHub Desktop.
SVG Sprite for Plei
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Usage | |
# = svg_icon_tag 'social-icons.svg', 'twitter-icon' | |
module SvgHelper | |
def svg_icon_tag(source, name, options = {}) | |
svg_tag_options = options.merge(class: ['symbol', name, options[:class]].reject(&:blank?).join(' ')) | |
content_tag(:svg, svg_tag_options) do | |
content_tag(:use, nil, "xlink:href" => "#{path_to_image(source)}##{name}") | |
end | |
end | |
# Inline svg from @tomeara https://gist.github.com/tomeara/6515860 | |
# or add #https://github.com/Keyamoon/svgxuse for IE | |
def inline_svg(source) | |
file = File.open("app/assets/images/#{source}", "rb") | |
raw file.read | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment