Allow the cache buster in image-url() to be disabled on a per-call basis.
This commit is contained in:
parent
a89d61ce21
commit
93040322b3
@ -22,6 +22,9 @@ The Documentation for the [latest preview release](http://beta.compass-style.org
|
||||
* Compass now depends on Sass 3.1. You can install the preview release:
|
||||
`gem install sass --pre`. Note: you must also upgrade your haml gem if you
|
||||
use both in the same application.
|
||||
* A third argument is now available on the `image-url()` helper. When `true` or
|
||||
`false`, it will enable/disable the cache buster for a single image url. Or when
|
||||
a string, it will be the cache buster used.
|
||||
|
||||
0.11.alpha.1 (11/22/2010)
|
||||
-------------------------
|
||||
|
@ -43,11 +43,15 @@ classnames:
|
||||
#image-url.helper
|
||||
%h3
|
||||
%a(href="#image-url")
|
||||
image-url($path, $only-path: false)
|
||||
image-url($path, $only-path: false, $cache-buster: true)
|
||||
.details
|
||||
%p
|
||||
Generates a path to an asset found relative to the project's images directory.
|
||||
%br
|
||||
%p
|
||||
Passing a true value as the second argument will cause the only the path to be returned
|
||||
instead of a `url()` function
|
||||
%p
|
||||
The third argument is used to control the cache buster on a per-use basis.
|
||||
When set to `false` no cache buster will be used. When a string, that
|
||||
value will be used as the cache buster.
|
||||
|
||||
|
@ -288,7 +288,9 @@ module Compass::SassExtensions::Functions::Sprites
|
||||
missing_sprite!("sprite-url")
|
||||
end
|
||||
map.generate
|
||||
image_url(Sass::Script::String.new("#{map.path}-#{map.uniqueness_hash}.png"))
|
||||
image_url(Sass::Script::String.new("#{map.path}-#{map.uniqueness_hash}.png"),
|
||||
Sass::Script::Bool.new(false),
|
||||
Sass::Script::Bool.new(false))
|
||||
end
|
||||
Sass::Script::Functions.declare :sprite_url, [:map]
|
||||
|
||||
|
@ -18,6 +18,8 @@ module Compass::SassExtensions::Functions::Urls
|
||||
clean_url(path)
|
||||
end
|
||||
end
|
||||
Sass::Script::Functions.declare :stylesheet_url, [:path]
|
||||
Sass::Script::Functions.declare :stylesheet_url, [:path, :only_path]
|
||||
|
||||
def font_url(path, only_path = Sass::Script::Bool.new(false))
|
||||
path = path.value # get to the string value of the literal.
|
||||
@ -43,8 +45,10 @@ module Compass::SassExtensions::Functions::Urls
|
||||
clean_url(path)
|
||||
end
|
||||
end
|
||||
Sass::Script::Functions.declare :font_url, [:path]
|
||||
Sass::Script::Functions.declare :font_url, [:path, :only_path]
|
||||
|
||||
def image_url(path, only_path = Sass::Script::Bool.new(false))
|
||||
def image_url(path, only_path = Sass::Script::Bool.new(false), cache_buster = Sass::Script::Bool.new(true))
|
||||
path = path.value # get to the string value of the literal.
|
||||
|
||||
if path =~ %r{^#{Regexp.escape(Compass.configuration.http_images_path)}/(.*)}
|
||||
@ -83,9 +87,15 @@ module Compass::SassExtensions::Functions::Urls
|
||||
end
|
||||
|
||||
# Compute and append the cache buster if there is one.
|
||||
if cache_buster.to_bool
|
||||
if cache_buster.is_a?(Sass::Script::String)
|
||||
path += "?#{cache_buster.value}"
|
||||
else
|
||||
if buster = compute_cache_buster(path, real_path)
|
||||
path += "?#{buster}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# prepend the asset host if there is one.
|
||||
path = "#{asset_host}#{'/' unless path[0..0] == "/"}#{path}" if asset_host
|
||||
@ -96,6 +106,9 @@ module Compass::SassExtensions::Functions::Urls
|
||||
clean_url(path)
|
||||
end
|
||||
end
|
||||
Sass::Script::Functions.declare :image_url, [:path]
|
||||
Sass::Script::Functions.declare :image_url, [:path, :only_path]
|
||||
Sass::Script::Functions.declare :image_url, [:path, :only_path, :cache_buster]
|
||||
|
||||
private
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
.showgrid { background-image: url('http://assets0.example.com/images/grid.png?busted=true'); }
|
||||
|
||||
.inlinegrid { background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAUEAYAAACv1qP4AAAABmJLR0T///////8JWPfcAAAACXBIWXMAAABIAAAASABGyWs+AAAAZ0lEQVRYw+3QwQ2AIBAFUTEUwI3+uzN7gDscsIgxEuO8An52J11X73OudfxMraXkzHfO3Y98nQEhA0IGhAwIGRAyIGRAyICQASEDQgaEDAgZEDIgZEDIgJABoZzSGK3tPuN9ERFP7Nw4fg+c5g8V1wAAAABJRU5ErkJggg=='); }
|
||||
|
||||
.no-buster { background-image: url('http://assets0.example.com/images/grid.png'); }
|
||||
|
@ -3,3 +3,6 @@
|
||||
|
||||
.inlinegrid
|
||||
background-image: inline-image(unquote("grid.png"))
|
||||
|
||||
.no-buster
|
||||
background-image: image-url("grid.png", $only-path: false, $cache-buster: false)
|
||||
|
Loading…
Reference in New Issue
Block a user