Skip to content

Instantly share code, notes, and snippets.

@garrettheaver
Created November 25, 2015 19:20
Show Gist options
  • Save garrettheaver/582929bb309b0404ec8e to your computer and use it in GitHub Desktop.
Save garrettheaver/582929bb309b0404ec8e to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'nokogiri'
ARGV.each do |path|
name = File.basename(path, '.svg')
doc = Nokogiri::XML(File.read(path))
doc.xpath('//@id').remove
doc.xpath('//@fill').each{ |a| a.value = '#{$color0}' }
puts <<-EOF
@mixin icon-#{name.gsub('_', '-')}($color0) {
background-image: svg-url('#{doc.root.to_s.gsub(/\n/,'')}');
}
EOF
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment