From 06c2b43f36c84ddd3e17ada057b3dc621d4140f0 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 13 Mar 2006 01:33:57 +0000 Subject: Rendering xml shouldnt happen inside any layout. Added class proxying to RJS, so you can call page.field.clear("my_field") to generate Field.clear("my_field");. Added :content_type option to render, so you can change the content type on the fly. Do type/subtype reordering of Accept header preferences for xml types (aka make Firefox work with respond_to). CHANGED DEFAULT: The default content type for .rxml is now application/xml instead of type/xml, see http://www.xml.com/pub/a/2004/07/21/dive.html for reason git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3852 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_view/base.rb | 2 +- .../lib/action_view/helpers/prototype_helper.rb | 42 ++++++++++++---------- 2 files changed, 24 insertions(+), 20 deletions(-) (limited to 'actionpack/lib/action_view') diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index d2f4764575..95afff0e84 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -406,7 +406,7 @@ module ActionView #:nodoc: body = case extension.to_sym when :rxml "xml = Builder::XmlMarkup.new(:indent => 2)\n" + - "@controller.headers['Content-Type'] ||= 'text/xml'\n" + + "@controller.headers['Content-Type'] ||= 'application/xml'\n" + template when :rjs "@controller.headers['Content-Type'] ||= 'text/javascript'\n" + diff --git a/actionpack/lib/action_view/helpers/prototype_helper.rb b/actionpack/lib/action_view/helpers/prototype_helper.rb index 113ddc8739..1f6aa274db 100644 --- a/actionpack/lib/action_view/helpers/prototype_helper.rb +++ b/actionpack/lib/action_view/helpers/prototype_helper.rb @@ -618,29 +618,33 @@ module ActionView end private - def page - self - end + def page + self + end - def record(line) - returning line = "#{line.to_s.chomp.gsub /\;$/, ''};" do - self << line + def record(line) + returning line = "#{line.to_s.chomp.gsub /\;$/, ''};" do + self << line + end end - end - def render(*options_for_render) - Hash === options_for_render.first ? - @context.render(*options_for_render) : - options_for_render.first.to_s - end + def render(*options_for_render) + Hash === options_for_render.first ? + @context.render(*options_for_render) : + options_for_render.first.to_s + end - def javascript_object_for(object) - object.respond_to?(:to_json) ? object.to_json : object.inspect - end + def javascript_object_for(object) + object.respond_to?(:to_json) ? object.to_json : object.inspect + end - def arguments_for_call(arguments) - arguments.map { |argument| javascript_object_for(argument) }.join ', ' - end + def arguments_for_call(arguments) + arguments.map { |argument| javascript_object_for(argument) }.join ', ' + end + + def method_missing(method, *arguments) + JavaScriptProxy.new(self, method.to_s.camelize) + end end end @@ -718,7 +722,7 @@ module ActionView if method.to_s =~ /(.*)=$/ assign($1, arguments.first) else - call("#{method.to_s.first}#{method.to_s.classify[1..-1]}", *arguments) + call("#{method.to_s.first}#{method.to_s.camelize[1..-1]}", *arguments) end end -- cgit v1.2.3