Skip to content

Instantly share code, notes, and snippets.

@chriseppstein
Created November 2, 2011 14:52
Show Gist options
  • Select an option

  • Save chriseppstein/1333822 to your computer and use it in GitHub Desktop.

Select an option

Save chriseppstein/1333822 to your computer and use it in GitHub Desktop.
generate an inline sprite.
@include "icon/*.png";
#{$icon-sprite-base-class} {
background-image: inline-sprite($icon-sprites);
}
# copy this to your compass config.
module Sass::Script::Functions
def sprite_path(map)
Sass::Script::String.new("#{map.path}-s#{map.uniqueness_hash}.png")
end
declare :sprite_path, [:map]
def inline_sprite(map)
verify_map(map, "sprite-url")
map.generate
inline_image(sprite_path(map))
end
declare :inline_sprite, [:map]
end
@chriseppstein
Copy link
Copy Markdown
Author

I used to think it was kind of pointless, but @hcatlin pointed out that a sprite map is smaller than the individual files so there is some win here.

@scottdavis
Copy link
Copy Markdown

how about a config variable to toggle the desired output? like $icon-inline:true;

@chriseppstein
Copy link
Copy Markdown
Author

chriseppstein commented Nov 4, 2011 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment