Last active
October 13, 2015 06:17
-
-
Save morewry/4151748 to your computer and use it in GitHub Desktop.
Customize compass sprite selectors as automatically as possible
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
# http://stackoverflow.com/questions/10314907/getting-a-list-of-files-in-sass-compass | |
require File.join(File.dirname(__FILE__), 'listfiles.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
// http://compass-style.org/help/tutorials/spriting/magic-selectors/ | |
// http://stackoverflow.com/questions/10314907/getting-a-list-of-files-in-sass-compass | |
@import "icons/*.png"; | |
@each $file in listFiles("images/icons/*.png") { | |
.#{$file} { | |
// %#{$file} { for placeholder | |
@include icons-sprite($file); | |
} | |
} |
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
# http://stackoverflow.com/questions/10314907/getting-a-list-of-files-in-sass-compass | |
module Sass::Script::Functions | |
def listFiles(path) | |
return Sass::Script::List.new( | |
Dir.glob(path.value).map! { |x| Sass::Script::String.new(File.basename(x, '.*')) }, | |
:comma | |
) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment