mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
e56c635427
Makes caching a collection of template partials faster using `read_multi` on the Rails cache store. Some caching implementations have optimized `read_multi` so we don't have to check in the cache store for every template.
55 lines
1.7 KiB
Ruby
55 lines
1.7 KiB
Ruby
require "action_view"
|
|
require "rails"
|
|
|
|
module ActionView
|
|
# = Action View Railtie
|
|
class Railtie < Rails::Railtie # :nodoc:
|
|
config.action_view = ActiveSupport::OrderedOptions.new
|
|
config.action_view.embed_authenticity_token_in_remote_forms = false
|
|
|
|
config.eager_load_namespaces << ActionView
|
|
|
|
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
|
|
|
|
initializer "action_view.logger" do
|
|
ActiveSupport.on_load(:action_view) { self.logger ||= Rails.logger }
|
|
end
|
|
|
|
initializer "action_view.set_configs" do |app|
|
|
ActiveSupport.on_load(:action_view) do
|
|
app.config.action_view.each do |k,v|
|
|
send "#{k}=", v
|
|
end
|
|
end
|
|
end
|
|
|
|
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
|
|
|
|
initializer "action_view.collection_caching" do |app|
|
|
ActiveSupport.on_load(:action_controller) do
|
|
PartialRenderer.collection_cache = app.config.action_controller.cache_store
|
|
end
|
|
end
|
|
|
|
initializer "action_view.setup_action_pack" do |app|
|
|
ActiveSupport.on_load(:action_controller) do
|
|
ActionView::RoutingUrlFor.include(ActionDispatch::Routing::UrlFor)
|
|
end
|
|
end
|
|
|
|
rake_tasks do
|
|
load "action_view/tasks/dependencies.rake"
|
|
end
|
|
end
|
|
end
|