From f21a528f5508430bf9281dffe938bda6c9fbd84b Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Fri, 15 Jun 2012 17:17:21 +0200 Subject: Remove Mime::Type translations from Action View Action View should not be responsible for translating mime types. Any translation that's needed should be handled at controller level. --- actionpack/lib/action_view/template.rb | 6 +++--- actionpack/lib/action_view/template/handlers/builder.rb | 2 +- actionpack/lib/action_view/template/resolver.rb | 2 +- actionpack/lib/action_view/template/text.rb | 11 +++++------ 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb index a04eac1d3f..8c9310533c 100644 --- a/actionpack/lib/action_view/template.rb +++ b/actionpack/lib/action_view/template.rb @@ -121,7 +121,7 @@ module ActionView @locals = details[:locals] || [] @virtual_path = details[:virtual_path] @updated_at = details[:updated_at] || Time.now - @formats = Array(format).map { |f| f.is_a?(Mime::Type) ? f.ref : f } + @formats = Array(format).map { |f| f.to_sym } @compile_mutex = Mutex.new end @@ -146,8 +146,8 @@ module ActionView handle_render_error(view, e) end - def mime_type - @mime_type ||= Mime::Type.lookup_by_extension(@formats.first.to_s) if @formats.first + def type + @type ||= @formats.first.to_sym if @formats.first end # Receives a view object and return a template similar to self by using @virtual_path. diff --git a/actionpack/lib/action_view/template/handlers/builder.rb b/actionpack/lib/action_view/template/handlers/builder.rb index 34397c3bcf..d90b0c6378 100644 --- a/actionpack/lib/action_view/template/handlers/builder.rb +++ b/actionpack/lib/action_view/template/handlers/builder.rb @@ -3,7 +3,7 @@ module ActionView class Builder # Default format used by Builder. class_attribute :default_format - self.default_format = Mime::XML + self.default_format = :xml def call(template) require_engine diff --git a/actionpack/lib/action_view/template/resolver.rb b/actionpack/lib/action_view/template/resolver.rb index 2bb656fac9..a8c8e919e2 100644 --- a/actionpack/lib/action_view/template/resolver.rb +++ b/actionpack/lib/action_view/template/resolver.rb @@ -235,7 +235,7 @@ module ActionView extension = pieces.pop ActiveSupport::Deprecation.warn "The file #{path} did not specify a template handler. The default is currently ERB, but will change to RAW in the future." unless extension handler = Template.handler_for_extension(extension) - format = pieces.last && Mime[pieces.last] + format = pieces.last && pieces.last.to_sym [handler, format] end end diff --git a/actionpack/lib/action_view/template/text.rb b/actionpack/lib/action_view/template/text.rb index 3af76dfcdb..b629faaa9a 100644 --- a/actionpack/lib/action_view/template/text.rb +++ b/actionpack/lib/action_view/template/text.rb @@ -2,12 +2,11 @@ module ActionView #:nodoc: # = Action View Text Template class Template class Text #:nodoc: - attr_accessor :mime_type + attr_accessor :type - def initialize(string, mime_type = nil) - @string = string.to_s - @mime_type = Mime[mime_type] || mime_type if mime_type - @mime_type ||= Mime::TEXT + def initialize(string, type = nil) + @string = string.to_s + @type = type || :text end def identifier @@ -27,7 +26,7 @@ module ActionView #:nodoc: end def formats - [@mime_type.to_sym] + [@type.to_sym] end end end -- cgit v1.2.3