2017-07-23 15:36:41 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2009-12-31 20:28:48 +00:00
|
|
|
require "action_view"
|
2010-01-12 23:41:04 +00:00
|
|
|
require "rails"
|
|
|
|
|
|
|
|
module ActionView
|
2010-06-16 18:27:50 +00:00
|
|
|
# = Action View Railtie
|
2016-11-25 16:10:52 +00:00
|
|
|
class Railtie < Rails::Engine # :nodoc:
|
2010-03-26 17:47:55 +00:00
|
|
|
config.action_view = ActiveSupport::OrderedOptions.new
|
2017-03-23 20:43:11 +00:00
|
|
|
config.action_view.embed_authenticity_token_in_remote_forms = nil
|
2015-12-01 15:49:44 +00:00
|
|
|
config.action_view.debug_missing_translation = true
|
2018-02-27 11:07:04 +00:00
|
|
|
config.action_view.default_enforce_utf8 = nil
|
2020-02-13 23:48:21 +00:00
|
|
|
config.action_view.image_loading = nil
|
2020-12-14 17:39:26 +00:00
|
|
|
config.action_view.image_decoding = nil
|
2021-01-27 00:31:16 +00:00
|
|
|
config.action_view.apply_stylesheet_media_default = true
|
2012-03-28 02:03:50 +00:00
|
|
|
|
2012-08-01 18:54:22 +00:00
|
|
|
config.eager_load_namespaces << ActionView
|
|
|
|
|
2019-12-18 16:23:50 +00:00
|
|
|
config.after_initialize do |app|
|
|
|
|
ActionView::Helpers::FormTagHelper.embed_authenticity_token_in_remote_forms =
|
|
|
|
app.config.action_view.delete(:embed_authenticity_token_in_remote_forms)
|
2012-03-28 02:03:50 +00:00
|
|
|
end
|
2010-06-22 22:30:22 +00:00
|
|
|
|
2019-12-18 16:23:50 +00:00
|
|
|
config.after_initialize do |app|
|
|
|
|
form_with_generates_remote_forms = app.config.action_view.delete(:form_with_generates_remote_forms)
|
|
|
|
ActionView::Helpers::FormHelper.form_with_generates_remote_forms = form_with_generates_remote_forms
|
|
|
|
end
|
|
|
|
|
|
|
|
config.after_initialize do |app|
|
|
|
|
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
|
2017-04-21 16:23:49 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-12-18 16:23:50 +00:00
|
|
|
config.after_initialize do |app|
|
|
|
|
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
|
2017-06-13 14:54:35 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-01-08 14:10:39 +00:00
|
|
|
config.after_initialize do |app|
|
|
|
|
button_to_generates_button_tag = app.config.action_view.delete(:button_to_generates_button_tag)
|
|
|
|
unless button_to_generates_button_tag.nil?
|
|
|
|
ActionView::Helpers::UrlHelper.button_to_generates_button_tag = button_to_generates_button_tag
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-11-26 09:41:49 +00:00
|
|
|
config.after_initialize do |app|
|
|
|
|
frozen_string_literal = app.config.action_view.delete(:frozen_string_literal)
|
|
|
|
ActionView::Template.frozen_string_literal = frozen_string_literal
|
|
|
|
end
|
|
|
|
|
2020-02-13 23:48:21 +00:00
|
|
|
config.after_initialize do |app|
|
|
|
|
ActionView::Helpers::AssetTagHelper.image_loading = app.config.action_view.delete(:image_loading)
|
2020-12-14 17:39:26 +00:00
|
|
|
ActionView::Helpers::AssetTagHelper.image_decoding = app.config.action_view.delete(:image_decoding)
|
2020-12-18 19:11:16 +00:00
|
|
|
ActionView::Helpers::AssetTagHelper.preload_links_header = app.config.action_view.delete(:preload_links_header)
|
2021-01-27 01:40:54 +00:00
|
|
|
ActionView::Helpers::AssetTagHelper.apply_stylesheet_media_default = app.config.action_view.delete(:apply_stylesheet_media_default)
|
2020-02-13 23:48:21 +00:00
|
|
|
end
|
|
|
|
|
2019-12-18 16:23:50 +00:00
|
|
|
config.after_initialize do |app|
|
2018-02-27 11:07:04 +00:00
|
|
|
ActiveSupport.on_load(:action_view) do
|
2019-12-18 16:23:50 +00:00
|
|
|
app.config.action_view.each do |k, v|
|
|
|
|
send "#{k}=", v
|
2018-02-27 11:07:04 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-01-18 17:05:36 +00:00
|
|
|
initializer "action_view.logger" do
|
|
|
|
ActiveSupport.on_load(:action_view) { self.logger ||= Rails.logger }
|
|
|
|
end
|
|
|
|
|
2010-12-16 20:37:48 +00:00
|
|
|
initializer "action_view.caching" do |app|
|
|
|
|
ActiveSupport.on_load(:action_view) do
|
|
|
|
if app.config.action_view.cache_template_loading.nil?
|
2022-04-14 16:11:36 +00:00
|
|
|
ActionView::Resolver.caching = !app.config.reloading_enabled?
|
2010-12-16 20:37:48 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2013-06-26 12:48:40 +00:00
|
|
|
|
2013-12-05 18:34:22 +00:00
|
|
|
initializer "action_view.setup_action_pack" do |app|
|
2013-06-26 12:48:40 +00:00
|
|
|
ActiveSupport.on_load(:action_controller) do
|
2015-02-01 04:12:37 +00:00
|
|
|
ActionView::RoutingUrlFor.include(ActionDispatch::Routing::UrlFor)
|
2013-06-26 12:48:40 +00:00
|
|
|
end
|
|
|
|
end
|
2013-07-17 13:13:16 +00:00
|
|
|
|
2016-04-27 21:21:10 +00:00
|
|
|
initializer "action_view.collection_caching", after: "action_controller.set_configs" do |app|
|
|
|
|
PartialRenderer.collection_cache = app.config.action_controller.cache_store
|
|
|
|
end
|
|
|
|
|
2019-12-18 16:23:50 +00:00
|
|
|
config.after_initialize do |app|
|
|
|
|
enable_caching = if app.config.action_view.cache_template_loading.nil?
|
2022-04-14 16:11:36 +00:00
|
|
|
!app.config.reloading_enabled?
|
2019-12-18 16:23:50 +00:00
|
|
|
else
|
|
|
|
app.config.action_view.cache_template_loading
|
|
|
|
end
|
|
|
|
|
|
|
|
unless enable_caching
|
2021-04-11 05:07:09 +00:00
|
|
|
app.executor.register_hook ActionView::CacheExpiry::Executor.new(watcher: app.config.file_watcher)
|
2019-12-18 16:23:50 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-05-05 17:42:39 +00:00
|
|
|
rake_tasks do |app|
|
|
|
|
unless app.config.api_only
|
2016-03-09 23:32:11 +00:00
|
|
|
load "action_view/tasks/cache_digests.rake"
|
2015-05-05 17:42:39 +00:00
|
|
|
end
|
2013-09-26 19:19:19 +00:00
|
|
|
end
|
2010-01-12 23:41:04 +00:00
|
|
|
end
|
2010-12-16 20:37:48 +00:00
|
|
|
end
|