Merge commit 'psampaio/sprite_skip_overrides'
* commit 'psampaio/sprite_skip_overrides': adding --skip-overrides argument to the compass sprite command
This commit is contained in:
commit
d3a346e1ac
@ -8,6 +8,9 @@ module Compass
|
||||
opts.on("-f SPRITE_FILE") do |output_file|
|
||||
self.options[:output_file] = output_file
|
||||
end
|
||||
opts.on("--skip-overrides", "Skip the generation of sprite overrides") do |skip_overrides|
|
||||
self.options[:skip_overrides] = skip_overrides
|
||||
end
|
||||
opts.banner = %Q{
|
||||
Usage: compass sprite [options] "images/path/to/sprites/*.png"
|
||||
|
||||
@ -41,7 +44,8 @@ module Compass
|
||||
image_names = sprite_images.map{|i| File.basename(i, '.png')}
|
||||
sprites.path, sprites.name = Compass::Sprites.path_and_name(relative_uri)
|
||||
options[:output_file] ||= File.join(Compass.configuration.sass_path, "sprites", "_#{sprites.name}.#{Compass.configuration.preferred_syntax}")
|
||||
contents = sprites.content_for_images(relative_uri, sprites.name, image_names)
|
||||
options[:skip_overrides] ||= false
|
||||
contents = sprites.content_for_images(relative_uri, sprites.name, image_names, options[:skip_overrides])
|
||||
if options[:output_file][-4..-1] != "scss"
|
||||
contents = Sass::Engine.new(contents, Compass.sass_engine_options.merge(:syntax => :scss)).to_tree.to_sass
|
||||
end
|
||||
|
@ -35,7 +35,7 @@ module Compass
|
||||
end
|
||||
end
|
||||
|
||||
def content_for_images(uri, name, images)
|
||||
def content_for_images(uri, name, images, skip_overrides = false)
|
||||
<<-SCSS
|
||||
@import "compass/utilities/sprites/base";
|
||||
|
||||
@ -47,22 +47,7 @@ $#{name}-position: 0% !default;
|
||||
$#{name}-spacing: 0 !default;
|
||||
$#{name}-repeat: no-repeat !default;
|
||||
|
||||
// These variables control the generated sprite output
|
||||
// You can override them selectively before you import this file.
|
||||
#{images.map do |sprite_name|
|
||||
<<-SCSS
|
||||
$#{name}-#{sprite_name}-position: $#{name}-position !default;
|
||||
$#{name}-#{sprite_name}-spacing: $#{name}-spacing !default;
|
||||
$#{name}-#{sprite_name}-repeat: $#{name}-repeat !default;
|
||||
SCSS
|
||||
end.join}
|
||||
|
||||
$#{name}-sprites: sprite-map("#{uri}",
|
||||
#{images.map do |sprite_name|
|
||||
%Q{ $#{sprite_name}-position: $#{name}-#{sprite_name}-position,
|
||||
$#{sprite_name}-spacing: $#{name}-#{sprite_name}-spacing,
|
||||
$#{sprite_name}-repeat: $#{name}-#{sprite_name}-repeat}
|
||||
end.join(",\n")});
|
||||
#{skip_overrides ? "$#{name}-sprites: sprite-map(\"#{uri}\");" : generate_overrides(uri, name, images) }
|
||||
|
||||
// All sprites should extend this class
|
||||
// The #{name}-sprite mixin will do so for you.
|
||||
@ -118,5 +103,25 @@ SCSS
|
||||
""
|
||||
end
|
||||
|
||||
def generate_overrides(uri, name,images)
|
||||
content = <<-TXT
|
||||
// These variables control the generated sprite output
|
||||
// You can override them selectively before you import this file.
|
||||
TXT
|
||||
images.map do |sprite_name|
|
||||
content += <<-SCSS
|
||||
$#{name}-#{sprite_name}-position: $#{name}-position !default;
|
||||
$#{name}-#{sprite_name}-spacing: $#{name}-spacing !default;
|
||||
$#{name}-#{sprite_name}-repeat: $#{name}-repeat !default;
|
||||
SCSS
|
||||
end.join
|
||||
content += "\n$#{name}-sprites: sprite-map(\"#{uri}\",\n"
|
||||
content += images.map do |sprite_name|
|
||||
%Q{ $#{sprite_name}-position: $#{name}-#{sprite_name}-position,
|
||||
$#{sprite_name}-spacing: $#{name}-#{sprite_name}-spacing,
|
||||
$#{sprite_name}-repeat: $#{name}-#{sprite_name}-repeat}
|
||||
end.join(",\n")
|
||||
content += ");"
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user