Class: Sprockets::Svg::Cleaner
- Inherits:
-
Object
- Object
- Sprockets::Svg::Cleaner
- Defined in:
- lib/sprockets/svg/cleaner.rb
Class Method Summary collapse
- .call(input) ⇒ Object
-
.process(svg) ⇒ Object
TODO: integrate svgo instead: github.com/svg/svgo See github.com/lautis/uglifier on how to integrate a npm package as a gem.
Class Method Details
.call(input) ⇒ Object
15 16 17 |
# File 'lib/sprockets/svg/cleaner.rb', line 15 def self.call(input) process(input[:data]) end |
.process(svg) ⇒ Object
TODO: integrate svgo instead: github.com/svg/svgo See github.com/lautis/uglifier on how to integrate a npm package as a gem.
8 9 10 11 12 13 |
# File 'lib/sprockets/svg/cleaner.rb', line 8 def self.process(svg) document = Nokogiri::XML(svg).css('svg') document.css('[display=none]').remove document.xpath('//comment()').remove document.to_s.gsub("\n", '').gsub(/>\s+</, '><').strip end |