From 45efb665f0dc10cd6f8e186b06765693fda6251b Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Fri, 15 Jun 2012 20:36:09 +0200 Subject: Add ActionView::Base.default_formats default_formats array is used by LookupContext in order to allow rendering templates when :formats option is not passed. Previously it was always set to Mime::SET, which created dependency on Action Pack. In order to remove this dependency, Mime::SET is used only if ActionController is loaded. --- actionpack/lib/action_dispatch.rb | 4 ++++ actionpack/lib/action_view/base.rb | 3 +++ actionpack/lib/action_view/lookup_context.rb | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_dispatch.rb b/actionpack/lib/action_dispatch.rb index 57b4678add..bef18a9e81 100644 --- a/actionpack/lib/action_dispatch.rb +++ b/actionpack/lib/action_dispatch.rb @@ -101,3 +101,7 @@ module ActionDispatch end autoload :Mime, 'action_dispatch/http/mime_type' + +ActiveSupport.on_load(:action_view) do + ActionView::Base.default_formats ||= Mime::SET.symbols +end diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index e51c75d73a..3464ec523e 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -146,6 +146,9 @@ module ActionView #:nodoc: cattr_accessor :prefix_partial_path_with_controller_namespace @@prefix_partial_path_with_controller_namespace = true + # Specify default_formats that can be rendered. + cattr_accessor :default_formats + class_attribute :_routes class_attribute :logger diff --git a/actionpack/lib/action_view/lookup_context.rb b/actionpack/lib/action_view/lookup_context.rb index f0ea92b018..af367ac28d 100644 --- a/actionpack/lib/action_view/lookup_context.rb +++ b/actionpack/lib/action_view/lookup_context.rb @@ -43,7 +43,7 @@ module ActionView end register_detail(:locale) { [I18n.locale, I18n.default_locale].uniq } - register_detail(:formats) { Mime::SET.symbols } + register_detail(:formats) { ActionView::Base.default_formats || [:html, :text, :js, :css, :xml, :json] } register_detail(:handlers){ Template::Handlers.extensions } class DetailsKey #:nodoc: -- cgit v1.2.3