diff --git a/lib/compass/sass_extensions/functions/sprites.rb b/lib/compass/sass_extensions/functions/sprites.rb index 1ab53e26..ab6bf017 100644 --- a/lib/compass/sass_extensions/functions/sprites.rb +++ b/lib/compass/sass_extensions/functions/sprites.rb @@ -34,6 +34,7 @@ module Compass::SassExtensions::Functions::Sprites # # background: url('/images/icons.png?12345678') 0 -24px no-repeat; def sprite(map, sprite, offset_x = ZERO, offset_y = ZERO) + sprite = convert_sprite(sprite) verify_map(map) unless sprite.is_a?(Sass::Script::String) raise Sass::SyntaxError, %Q(The second argument to sprite() must be a sprite name. See http://beta.compass-style.org/help/tutorials/spriting/ for more information.) @@ -56,6 +57,7 @@ module Compass::SassExtensions::Functions::Sprites # Returns the path to the original image file for the sprite with the given name def sprite_file(map, sprite) + sprite = convert_sprite(sprite) verify_map(map, "sprite") verify_sprite(sprite) if image = map.image_for(sprite.value) @@ -68,6 +70,7 @@ module Compass::SassExtensions::Functions::Sprites # Returns voolean if sprite has a parent def sprite_does_not_have_parent(map, sprite) + sprite = convert_sprite(sprite) verify_map map verify_sprite sprite Sass::Script::Bool.new map.image_for(sprite.value).parent.nil? @@ -77,6 +80,7 @@ module Compass::SassExtensions::Functions::Sprites # Returns boolean if sprite has the selector def sprite_has_selector(map, sprite, selector) + sprite = convert_sprite(sprite) verify_map map verify_sprite sprite unless VALID_SELECTORS.include?(selector.value) @@ -118,6 +122,7 @@ module Compass::SassExtensions::Functions::Sprites # # background-position: 3px -36px; def sprite_position(map, sprite = nil, offset_x = ZERO, offset_y = ZERO) + sprite = convert_sprite(sprite) verify_map(map, "sprite-position") unless sprite && sprite.is_a?(Sass::Script::String) raise Sass::SyntaxError, %Q(The second argument to sprite-position must be a sprite name. See http://beta.compass-style.org/help/tutorials/spriting/ for more information.) @@ -147,6 +152,13 @@ module Compass::SassExtensions::Functions::Sprites protected + def convert_sprite(sprite) + if sprite.is_a?(Sass::Script::Color) + return Sass::Script::String.new(sprite.to_s) + end + sprite + end + def verify_map(map, error = "sprite") unless map.is_a?(Compass::SassExtensions::Sprites::Base) missing_sprite!(error) diff --git a/test/integrations/sprites_test.rb b/test/integrations/sprites_test.rb index 549427d4..3f482e62 100644 --- a/test/integrations/sprites_test.rb +++ b/test/integrations/sprites_test.rb @@ -577,5 +577,15 @@ class SpritesTest < Test::Unit::TestCase SCSS assert_equal 2, map_files('selectors-*.png').size, "File was removed" end + + it "should generate a sprite if the sprite is a colorname" do + css = render <<-SCSS + @import "colors/*.png"; + a { + @include colors-sprite(blue); + } + SCSS + assert !css.empty? + end end \ No newline at end of file