twolfson / grunt-spritesmith

Grunt task for converting a set of images into a spritesheet and corresponding CSS variables
MIT License
1.14k stars 92 forks source link

filenames with double dash get variable name with single dash #141

Closed qikkeronline closed 9 years ago

qikkeronline commented 9 years ago

Hi there,

When I am using an image with the name image--name.png or image__name.png, spritesmith compiles the following back:

$image-name
$image_name

As I am using the BEM method, I'd like to be able to use it throughout the application - so also in variable names.

Is this intended behaviour, or is this something that can be fixed? I am using the scss output method by the way.

Thanks, and kind regards!

twolfson commented 9 years ago

We have case normalization for all of our templates. This is to allow the usage of - in image filenames, even if the CSS preprocessor doesn't allow it (e.g. Stylus prefers _). I am guessing the double delimiter is causing the library to throw away the extra delimiter rather than fully normalize.

To disable the normalization, we can use cssOpts to pass options to our template and tell our template to not use any normalization:

https://github.com/Ensighten/grunt-spritesmith/tree/5.0.0#documentation

https://github.com/twolfson/spritesheet-templates/tree/10.0.0#scss

{
  // src, dest
  cssOpts: {
    variableNameTransforms: []
  }
}
qikkeronline commented 9 years ago

Great, thanks!