lib/sprite/sass_extensions.rb in amikula-sprite-0.1.10 vs lib/sprite/sass_extensions.rb in amikula-sprite-0.1.11
- old
+ new
@@ -1,12 +1,29 @@
module Sprite
module Sass
module Extensions
+ def self.asset_id(&block)
+ @asset_id = block if block
+ end
+
+ def self.query_string_for(asset)
+ if @asset_id
+ "?#{@asset_id.call(asset)}"
+ else
+ ''
+ end
+ end
+
+ def sprite_path(group)
+ path = sprite_builder.image_path(group.value)
+ "#{path}#{Sprite::Sass::Extensions.query_string_for(path)}"
+ end
+
def sprite_background(group, image)
sprite = sprite_data(group, image)
if sprite
- sprite_path = sprite_builder.image_path(group.value)
+ sprite_path = sprite_path(group)
::Sass::Script::String.new "url('#{sprite_path}') no-repeat #{sprite[:x]}px #{sprite[:y]}px"
else
::Sass::Script::String.new ""
end
end
@@ -26,14 +43,14 @@
def sprite_y_offset(*args)
::Sass::Script::String.new sprite_attr(:y, *args)
end
def sprite_image(group)
- ::Sass::Script::String.new sprite_builder.image_path(group.value)
+ ::Sass::Script::String.new sprite_path(group)
end
def sprite_url(group)
- ::Sass::Script::String.new "url('#{sprite_image(group)}')"
+ ::Sass::Script::String.new "url('#{sprite_path(group)}')"
end
##
# Return a sprite offset for the given image. When the optional x and y values are passed,
# numeric values are treated as additional offsets to the sprite image offset. Any string