module Sprockets::PathUtils

def match_path_extname(path, extensions)

Returns [String extname, Object value] or nil nothing matched.

extensions - Hash of String extnames to values
path - String

Internal: Match path extnames against available extensions.
def match_path_extname(path, extensions)
  match, key = nil, ""
  path_extnames(path).reverse_each do |extname|
    key.prepend(extname)
    if value = extensions[key]
      match = [key.dup, value]
    elsif match
      break
    end
  end
  match
end