]> git.openstreetmap.org Git - rails.git/blob - config/initializers/action_view.rb
Moved note description to the sidebar header
[rails.git] / config / initializers / action_view.rb
1 #
2 # Make :formats work when rendering one partial from another
3 #
4 # Taken from https://github.com/rails/rails/pull/6626
5 #
6 module ActionView
7   class AbstractRenderer #:nodoc:
8     def prepend_formats(formats)
9       formats = Array(formats)
10       return if formats.empty?
11       @lookup_context.formats = formats | @lookup_context.formats
12     end
13   end
14
15   class PartialRenderer
16     def setup_with_formats(context, options, block)
17       prepend_formats(options[:formats])
18       setup_without_formats(context, options, block)
19     end
20
21     alias_method_chain :setup, :formats
22   end
23
24   class TemplateRenderer
25     def render_with_formats(context, options)
26       prepend_formats(options[:formats])
27       render_without_formats(context, options)
28     end
29
30     alias_method_chain :render, :formats
31   end
32 end