instance method extract_handler_and_format

Ruby on Rails 3.0.20

Since v3.0.20 Last seen in v3.0.20 Private

Signature

extract_handler_and_format(path, default_formats)

Extract handler and formats from path. If a format cannot be a found neither from the path, or the handler, we should return the array of formats given to the resolver.

Parameters

path req
default_formats req
Source
# File actionpack/lib/action_view/template/resolver.rb, line 98
    def extract_handler_and_format(path, default_formats)
      pieces = File.basename(path).split(".")
      pieces.shift

      handler  = Template.handler_class_for_extension(pieces.pop)

      if pieces.last == "html" && pieces[-2] == "text"
        correct_path = path.gsub(/\.text\.html/, ".html")
        ActiveSupport::Deprecation.warn "The file `#{path}` uses the deprecated format `text.html`. Please rename it to #{correct_path}", caller
      end

      if pieces.last == "plain" && pieces[-2] == "text"
        correct_path = path.gsub(/\.text\.plain/, ".text")
        pieces.pop
        ActiveSupport::Deprecation.warn "The file `#{path}` uses the deprecated format `text.plain`. Please rename it to #{correct_path}", caller
      end

      format   = pieces.last && Mime[pieces.last] && pieces.pop.to_sym
      format ||= handler.default_format if handler.respond_to?(:default_format)
      format ||= default_formats

      [handler, format]
    end

Defined in actionpack/lib/action_view/template/resolver.rb line 98 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionView::PathResolver

Type at least 2 characters to search.

↑↓ navigate · open · esc close