aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers
diff options
context:
space:
mode:
authorCarlhuda <carlhuda@engineyard.com>2010-03-01 14:37:05 -0800
committerCarlhuda <carlhuda@engineyard.com>2010-03-01 14:37:05 -0800
commitb85ea58eb561d0a0fd2b0a3dbae1dc7846961c2d (patch)
treecd6aff630ea6d1ebcbfde508fb35b8b4a1d8118b /actionpack/lib/action_view/helpers
parent8fbbdda52634991b047b7567fe3a8ec7c9a6c558 (diff)
downloadrails-b85ea58eb561d0a0fd2b0a3dbae1dc7846961c2d.tar.gz
rails-b85ea58eb561d0a0fd2b0a3dbae1dc7846961c2d.tar.bz2
rails-b85ea58eb561d0a0fd2b0a3dbae1dc7846961c2d.zip
Change AV formats so they can delegate to the controller. Now users (or plugins) can override details_for_render in their controllers and add appropriate additional details. Now if only they could *do* something with those details...
Diffstat (limited to 'actionpack/lib/action_view/helpers')
-rw-r--r--actionpack/lib/action_view/helpers/prototype_helper.rb32
1 files changed, 17 insertions, 15 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)