diff --git a/lib/compass/sprite_importer.rb b/lib/compass/sprite_importer.rb index 9478a0fe..3914cf67 100644 --- a/lib/compass/sprite_importer.rb +++ b/lib/compass/sprite_importer.rb @@ -2,13 +2,13 @@ require 'erb' require 'compass/sprite_importer/binding' module Compass class SpriteImporter < Sass::Importers::Base - VAILD_FILE_NAME = /\A#{Sass::SCSS::RX::IDENT}\Z/ + VAILD_FILE_NAME = /\A#{Sass::SCSS::RX::IDENT}\Z/ SPRITE_IMPORTER_REGEX = %r{((.+/)?([^\*.]+))/(.+?)\.png} - VALID_EXTENSIONS = ['.png'] + VALID_EXTENSIONS = ['.png'] - TEMPLATE_FOLDER = File.join(File.expand_path('../', __FILE__), 'sprite_importer') + TEMPLATE_FOLDER = File.join(File.expand_path('../', __FILE__), 'sprite_importer') CONTENT_TEMPLATE_FILE = File.join(TEMPLATE_FOLDER, 'content.erb') - CONTENT_TEMPLATE = ERB.new(File.read(CONTENT_TEMPLATE_FILE)) + CONTENT_TEMPLATE = ERB.new(File.read(CONTENT_TEMPLATE_FILE)) diff --git a/lib/compass/sprite_importer/content.erb b/lib/compass/sprite_importer/content.erb index ccc6144e..27400bed 100644 --- a/lib/compass/sprite_importer/content.erb +++ b/lib/compass/sprite_importer/content.erb @@ -2,18 +2,18 @@ // General Sprite Defaults // You can override them before you import this file. -$<%= name %>-sprite-base-class: ".<%= name %>-sprite" !default; -$<%= name %>-sprite-dimensions: false !default; -$<%= name %>-position: 0% !default; -$<%= name %>-spacing: 0 !default; -$<%= name %>-repeat: no-repeat !default; -$<%= name %>-prefix: '' !default; -$<%= name %>-clean-up: true !default; -$<%= name %>-layout:vertical !default; -$<%= name %>-inline: false !default; +$<%= name %>-sprite-base-class : ".<%= name %>-sprite" !default; +$<%= name %>-sprite-dimensions : false !default; +$<%= name %>-position : 0% !default; +$<%= name %>-spacing : 0 !default; +$<%= name %>-repeat : no-repeat !default; +$<%= name %>-prefix : '' !default; +$<%= name %>-clean-up : true !default; +$<%= name %>-layout : vertical !default; +$<%= name %>-inline : false !default; <% if skip_overrides %> - $<%= name %>-sprites: sprite-map("<%= uri %>", $layout: $<%= name %>-layout, $cleanup: $<%= name %>-clean-up); + $<%= name %>-sprites: sprite-map("<%= uri %>", $layout: $<%= name %>-layout, $cleanup: $<%= name %>-clean-up, $spacing: $<%= name %>-spacing, $position : $<%= name %>-position); <% else %> // These variables control the generated sprite output // You can override them selectively before you import this file. @@ -29,8 +29,10 @@ $<%= name %>-inline: false !default; $<%= name %>-<%= sprite_name %>-spacing: $<%= name %>-<%= sprite_name %>-spacing, $<%= name %>-<%= sprite_name %>-repeat: $<%= name %>-<%= sprite_name %>-repeat, <% end %> - $layout: $<%= name %>-layout, - $cleanup: $<%= name %>-clean-up + $layout : $<%= name %>-layout, + $cleanup : $<%= name %>-clean-up, + $spacing : $<%= name %>-spacing, + $position : $<%= name %>-position ); <% end %> diff --git a/test/integrations/sprites_test.rb b/test/integrations/sprites_test.rb index 3195ad44..f0dfbada 100644 --- a/test/integrations/sprites_test.rb +++ b/test/integrations/sprites_test.rb @@ -863,4 +863,24 @@ class SpritesTest < Test::Unit::TestCase end + it "should respect global spacing" do + css = render <<-SCSS + $colors-spacing:5px; + @import "colors/*.png"; + @include all-colors-sprites; + SCSS + other_css = <<-CSS + .colors-sprite, .colors-blue, .colors-yellow { + background: url('/colors-s747dec274e.png') no-repeat; + } + .colors-blue { + background-position:0 0; + } + .colors-yellow { + background-position:0 -15px; + } + CSS + assert_correct clean(css), clean(other_css) + end + end