2017-07-23 11:36:41 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2009-12-31 15:28:48 -05:00
|
|
|
require "action_view"
|
2010-01-12 18:41:04 -05:00
|
|
|
require "rails"
|
|
|
|
|
|
|
|
module ActionView
|
2010-06-16 14:27:50 -04:00
|
|
|
# = Action View Railtie
|
2016-11-25 11:10:52 -05:00
|
|
|
class Railtie < Rails::Engine # :nodoc:
|
2019-01-24 16:50:24 -05:00
|
|
|
NULL_OPTION = Object.new
|
|
|
|
|
2010-03-26 13:47:55 -04:00
|
|
|
config.action_view = ActiveSupport::OrderedOptions.new
|
2017-03-23 16:43:11 -04:00
|
|
|
config.action_view.embed_authenticity_token_in_remote_forms = nil
|
2015-12-01 10:49:44 -05:00
|
|
|
config.action_view.debug_missing_translation = true
|
2018-02-27 06:07:04 -05:00
|
|
|
config.action_view.default_enforce_utf8 = nil
|
2019-01-24 16:50:24 -05:00
|
|
|
config.action_view.finalize_compiled_template_methods = NULL_OPTION
|
2012-03-27 22:03:50 -04:00
|
|
|
|
2012-08-01 14:54:22 -04:00
|
|
|
config.eager_load_namespaces << ActionView
|
|
|
|
|
2012-03-27 22:03:50 -04:00
|
|
|
initializer "action_view.embed_authenticity_token_in_remote_forms" do |app|
|
|
|
|
ActiveSupport.on_load(:action_view) do
|
|
|
|
ActionView::Helpers::FormTagHelper.embed_authenticity_token_in_remote_forms =
|
|
|
|
app.config.action_view.delete(:embed_authenticity_token_in_remote_forms)
|
|
|
|
end
|
|
|
|
end
|
2010-06-22 18:30:22 -04:00
|
|
|
|
2017-04-21 12:23:49 -04:00
|
|
|
initializer "action_view.form_with_generates_remote_forms" do |app|
|
|
|
|
ActiveSupport.on_load(:action_view) do
|
2017-04-21 23:27:25 -04:00
|
|
|
form_with_generates_remote_forms = app.config.action_view.delete(:form_with_generates_remote_forms)
|
2017-11-25 11:49:01 -05:00
|
|
|
ActionView::Helpers::FormHelper.form_with_generates_remote_forms = form_with_generates_remote_forms
|
2017-04-21 12:23:49 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-06-13 10:54:35 -04:00
|
|
|
initializer "action_view.form_with_generates_ids" do |app|
|
|
|
|
ActiveSupport.on_load(:action_view) do
|
|
|
|
form_with_generates_ids = app.config.action_view.delete(:form_with_generates_ids)
|
|
|
|
unless form_with_generates_ids.nil?
|
|
|
|
ActionView::Helpers::FormHelper.form_with_generates_ids = form_with_generates_ids
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-02-27 06:07:04 -05:00
|
|
|
initializer "action_view.default_enforce_utf8" do |app|
|
|
|
|
ActiveSupport.on_load(:action_view) do
|
|
|
|
default_enforce_utf8 = app.config.action_view.delete(:default_enforce_utf8)
|
|
|
|
unless default_enforce_utf8.nil?
|
|
|
|
ActionView::Helpers::FormTagHelper.default_enforce_utf8 = default_enforce_utf8
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-01-24 16:50:24 -05:00
|
|
|
initializer "action_view.finalize_compiled_template_methods" do |app|
|
|
|
|
ActiveSupport.on_load(:action_view) do
|
|
|
|
option = app.config.action_view.delete(:finalize_compiled_template_methods)
|
|
|
|
|
|
|
|
if option != NULL_OPTION
|
|
|
|
ActiveSupport::Deprecation.warn "action_view.finalize_compiled_template_methods is deprecated and has no effect"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-01-18 12:05:36 -05:00
|
|
|
initializer "action_view.logger" do
|
|
|
|
ActiveSupport.on_load(:action_view) { self.logger ||= Rails.logger }
|
|
|
|
end
|
|
|
|
|
2010-03-26 13:47:55 -04:00
|
|
|
initializer "action_view.set_configs" do |app|
|
2010-03-29 20:08:08 -04:00
|
|
|
ActiveSupport.on_load(:action_view) do
|
2016-10-28 23:05:58 -04:00
|
|
|
app.config.action_view.each do |k, v|
|
2010-03-26 13:47:55 -04:00
|
|
|
send "#{k}=", v
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2010-12-16 15:37:48 -05:00
|
|
|
|
|
|
|
initializer "action_view.caching" do |app|
|
|
|
|
ActiveSupport.on_load(:action_view) do
|
|
|
|
if app.config.action_view.cache_template_loading.nil?
|
|
|
|
ActionView::Resolver.caching = app.config.cache_classes
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2013-06-26 08:48:40 -04:00
|
|
|
|
2015-05-30 17:11:49 -04:00
|
|
|
initializer "action_view.per_request_digest_cache" do |app|
|
|
|
|
ActiveSupport.on_load(:action_view) do
|
2016-12-05 13:30:27 -05:00
|
|
|
unless ActionView::Resolver.caching?
|
2019-04-01 15:22:57 -04:00
|
|
|
app.executor.to_run ActionView::CacheExpiry::Executor.new(watcher: app.config.file_watcher)
|
2015-05-30 17:11:49 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-12-05 13:34:22 -05:00
|
|
|
initializer "action_view.setup_action_pack" do |app|
|
2013-06-26 08:48:40 -04:00
|
|
|
ActiveSupport.on_load(:action_controller) do
|
2015-01-31 23:12:37 -05:00
|
|
|
ActionView::RoutingUrlFor.include(ActionDispatch::Routing::UrlFor)
|
2013-06-26 08:48:40 -04:00
|
|
|
end
|
|
|
|
end
|
2013-07-17 09:13:16 -04:00
|
|
|
|
2016-04-27 17:21:10 -04:00
|
|
|
initializer "action_view.collection_caching", after: "action_controller.set_configs" do |app|
|
|
|
|
PartialRenderer.collection_cache = app.config.action_controller.cache_store
|
|
|
|
end
|
|
|
|
|
2015-05-05 13:42:39 -04:00
|
|
|
rake_tasks do |app|
|
|
|
|
unless app.config.api_only
|
2016-03-09 18:32:11 -05:00
|
|
|
load "action_view/tasks/cache_digests.rake"
|
2015-05-05 13:42:39 -04:00
|
|
|
end
|
2013-09-26 15:19:19 -04:00
|
|
|
end
|
2010-01-12 18:41:04 -05:00
|
|
|
end
|
2010-12-16 15:37:48 -05:00
|
|
|
end
|