Skip to content

Instantly share code, notes, and snippets.

@StanAngeloff
Created June 18, 2011 20:46
Show Gist options
  • Save StanAngeloff/1033488 to your computer and use it in GitHub Desktop.
Save StanAngeloff/1033488 to your computer and use it in GitHub Desktop.
lib/compass/sass_extensions/functions/sprites.rb
# Returns the names of all sprites in a sprite map.
def sprite_names(map)
verify_map(map, "sprite-names")
Sass::Script::List.new(map.sprite_names.map { |sprite_name| Sass::Script::String.new(sprite_name) }, :comma)
end
Sass::Script::Functions.declare :sprite_names, [:map]
$icons: sprite-map('icons/*.png', $spacing: $default-icon-size * 8);
@each $sprite-name in sprite-names($icons) {
.my-icon-#{$sprite-name} {
...
}
}
// No need to declare a list of the icons,
// the list is instead generated dynamically.
// Add a file, re-compile and voila!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment