aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r--actionpack/lib/action_view/helpers/prototype_helper.rb32
-rw-r--r--actionpack/lib/action_view/render/rendering.rb8
2 files changed, 23 insertions, 17 deletions
diff --git a/actionpack/lib/action_view/helpers/prototype_helper.rb b/actionpack/lib/action_view/helpers/prototype_helper.rb
index 3c4511d931..67a7586699 100644
--- a/actionpack/lib/action_view/helpers/prototype_helper.rb
+++ b/actionpack/lib/action_view/helpers/prototype_helper.rb
@@ -182,14 +182,12 @@ module ActionView
def initialize(context, &block) #:nodoc:
context._evaluate_assigns_and_ivars
@context, @lines = context, []
- old_formats = @context.formats
- @context.reset_formats([:js, :html]) if @context
- include_helpers_from_context
- @context.with_output_buffer(@lines) do
- @context.instance_exec(self, &block)
+ @context.reset_formats([:js, :html]) do
+ include_helpers_from_context
+ @context.with_output_buffer(@lines) do
+ @context.instance_exec(self, &block)
+ end
end
- ensure
- @context.reset_formats(old_formats) if @context
end
private
@@ -573,15 +571,19 @@ module ActionView
end
end
- def render(*options_for_render)
- old_formats = @context && @context.formats
+ def render(*options)
+ with_formats(:html) do
+ case option = options.first
+ when Hash
+ @context.render(*options)
+ else
+ option.to_s
+ end
+ end
+ end
- @context.reset_formats([:html]) if @context
- Hash === options_for_render.first ?
- @context.render(*options_for_render) :
- options_for_render.first.to_s
- ensure
- @context.reset_formats(old_formats) if @context
+ def with_formats(*args)
+ @context ? @context.reset_formats(args) { yield } : yield
end
def javascript_object_for(object)
diff --git a/actionpack/lib/action_view/render/rendering.rb b/actionpack/lib/action_view/render/rendering.rb
index abc7c09991..64cc0caf11 100644
--- a/actionpack/lib/action_view/render/rendering.rb
+++ b/actionpack/lib/action_view/render/rendering.rb
@@ -25,7 +25,7 @@ module ActionView
end
template = if options[:file]
- find(options[:file], {:formats => formats})
+ find(options[:file], details_for_render)
elsif options[:inline]
handler = Template.handler_class_for_extension(options[:type] || "erb")
Template.new(options[:inline], "inline template", handler, {})
@@ -34,7 +34,7 @@ module ActionView
end
if template
- layout = find(layout, {:formats => formats}) if layout
+ layout = find(layout, details_for_render) if layout
_render_template(template, layout, :locals => options[:locals])
end
when :update
@@ -44,6 +44,10 @@ module ActionView
end
end
+ def details_for_render
+ controller.try(:details_for_render) || {:formats => formats}
+ end
+
# You can think of a layout as a method that is called with a block. _layout_for
# returns the contents that are yielded to the layout. If the user calls yield
# :some_name, the block, by default, returns content_for(:some_name). If the user