Skip to content

Instantly share code, notes, and snippets.

@pthrasher
Created July 27, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pthrasher/a641618d72fdcd616225 to your computer and use it in GitHub Desktop.
Save pthrasher/a641618d72fdcd616225 to your computer and use it in GitHub Desktop.
require 'json'
module Sass::Script::Functions
def get_md5s
md5sfile = File.join Dir.pwd, 'tmp/browser/cache/md5.json'
return JSON.parse(File.read(md5sfile))
end
def get_asset_url(string)
assert_type string, :String
value = string.value
md5s = get_md5s
if md5s[value].nil?
puts "Couldn't find asset path '#{value}'."
return Sass::Script::Value::String.new(value)
end
Sass::Script::Value::String.new(md5s[value][0]["fullUrl"])
end
declare :get_asset_url, [:string]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment