class Sprockets::Context
def resolve(path, options = {}, &block)
# => "/path/to/app/javascripts/bar.js"
resolve("./bar.js")
# => "/path/to/app/javascripts/foo.js"
resolve("foo.js")
search.
`:content_type` restriction can be supplied to restrict the
expanded path. Relative paths will also be resolved. An optional
Given a logical path, `resolve` will find and return the fully
def resolve(path, options = {}, &block) pathname = Pathname.new(path) attributes = environment.attributes_for(pathname) if pathname.absolute? if environment.stat(pathname) pathname else raise FileNotFound, "couldn't find file '#{pathname}'" end elsif content_type = options[:content_type] content_type = self.content_type if content_type == :self if attributes.format_extension if content_type != attributes.content_type raise ContentTypeMismatch, "#{path} is " + "'#{attributes.content_type}', not '#{content_type}'" end end resolve(path) do |candidate| if self.content_type == environment.content_type_of(candidate) return candidate end end raise FileNotFound, "couldn't find file '#{path}'" else environment.resolve(path, {:base_path => self.pathname.dirname}.merge(options), &block) end end