Created
June 18, 2011 20:46
-
-
Save StanAngeloff/1033488 to your computer and use it in GitHub Desktop.
lib/compass/sass_extensions/functions/sprites.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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