1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionview/lib/action_view/railtie.rb
Thomas von Deyen 1825f6fb60 Adds template dependencies rake task from cache_digests gem.
This adds the rake tasks `cache_digests:dependencies` and `cache_digests:nested_dependencies` from `cache_digests` gem.
2013-09-26 21:19:19 +02:00

56 lines
1.8 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.setup_action_pack", before: :add_view_paths do |app|
ActiveSupport.on_load(:action_controller) do
ActionController::Base.superclass.send(:include, ActionView::Layouts)
ActionView::RoutingUrlFor.send(:include, ActionDispatch::Routing::UrlFor)
end
end
initializer "action_view.setup_action_mailer", before: :add_view_paths do |app|
ActiveSupport.on_load(:action_mailer) do
ActionMailer::Base.send(:include, ActionView::Layouts)
end
end
rake_tasks do
load "action_view/tasks/dependencies.rake"
end
end
end