class MiddlemanScavenger
Extension namespace
Public Class Methods
new(app, options_hash={}, &block)
click to toggle source
Calls superclass method
# File lib/middleman-scavenger.rb, line 10 def initialize(app, options_hash={}, &block) super require "svg_processor" processor_instance = SVGProcessor.new(options.path, options.prefix, options.sprite_path) processor_instance.rebuild app.set :svg_processor, processor_instance app.set :svg_sprite_path, options.sprite_path app.ready do files.changed do |file| if File.extname(file) == ".svg" svg_processor.rebuild end end files.deleted do |file| if File.extname(file) == ".svg" svg_processor.rebuild end end end end
Public Instance Methods
inline_svg_sprite()
click to toggle source
# File lib/middleman-scavenger.rb, line 40 def inline_svg_sprite "<svg style=\"display:none;\">#{svg_processor.to_s}</svg>" end
scavenger_sprite_path()
click to toggle source
# File lib/middleman-scavenger.rb, line 36 def scavenger_sprite_path image_path File.basename(svg_sprite_path) end
svg(name, options=nil)
click to toggle source
# File lib/middleman-scavenger.rb, line 44 def svg(name, options=nil) if !options.nil? attrs = options.map {|k,v| "#{k}=\"#{v}\"" }.join(" ") "<svg #{attrs}><use xlink:href=\"##{name}\" /></svg>" else "<svg><use xlink:href=\"##{name}\" /></svg>" end end