jakesgordon/sprite-factory — Issue #11: sprite-factory assumes unique basenames are used
Author: nfm
Created: 2012-02-27 00:55:16+00:00
State: open

If you try to sprite a directory containing any images with the same basename, sprite-factory will only add the last of those images to the sprite and CSS.

For example:

/app/assets/images/sprites
-> /icons
-> /client.png
-> /titles
-> /client.png

Only /titles/client.png will be output in the sprite.

Even passing a block to `run!` to generate custom CSS can't fix this.

This issue occurs because when `SpriteFactory::Runner#style` is given a block to generate custom CSS, it creates a hash of images using `image[:name]`, which is non-unique, so the last image with a non-unique name is used.

I can't think of a way to fix this without breaking backwards compatibility. For example, creating a hash using `image[:filename]` instead of `image[:name]` would cause the examples in the README to fail.

Basically this comes down to namespacing images by directory (eg `/titles/icon.png`) instead of by filename (eg `/titles-icon.png`).

Can you think of any good ways to tackle this?