diff options
author | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-05-21 16:35:40 -0700 |
---|---|---|
committer | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-05-21 16:35:40 -0700 |
commit | 6923b392b740f2346326634532b40cf24a0f26ef (patch) | |
tree | 55a6486563e8d9a408c1dd8c7628e85c88af570e /actionpack/lib/action_controller/new_base | |
parent | e773d0e68ac64bd26d86860a9a8e0048e2b6bb48 (diff) | |
download | rails-6923b392b740f2346326634532b40cf24a0f26ef.tar.gz rails-6923b392b740f2346326634532b40cf24a0f26ef.tar.bz2 rails-6923b392b740f2346326634532b40cf24a0f26ef.zip |
Added the :rjs render option
Diffstat (limited to 'actionpack/lib/action_controller/new_base')
-rw-r--r-- | actionpack/lib/action_controller/new_base/base.rb | 14 | ||||
-rw-r--r-- | actionpack/lib/action_controller/new_base/render_options.rb | 11 |
2 files changed, 19 insertions, 6 deletions
diff --git a/actionpack/lib/action_controller/new_base/base.rb b/actionpack/lib/action_controller/new_base/base.rb index 034e614d6e..fae08c58b2 100644 --- a/actionpack/lib/action_controller/new_base/base.rb +++ b/actionpack/lib/action_controller/new_base/base.rb @@ -13,6 +13,7 @@ module ActionController include ActionController::Renderer include ActionController::Renderers::Json include ActionController::Renderers::Xml + include ActionController::Renderers::Rjs include ActionController::Layouts include ActionController::ConditionalGet @@ -74,7 +75,7 @@ module ActionController end end - def _normalize_options(action = nil, options = {}) + def _normalize_options(action = nil, options = {}, &blk) if action.is_a?(Hash) options, action = action, nil elsif action.is_a?(String) || action.is_a?(Symbol) @@ -93,19 +94,20 @@ module ActionController end if options[:status] - options[:status] = interpret_status(options.delete(:status)).to_i + options[:status] = interpret_status(options[:status]).to_i end + options[:update] = blk if block_given? options end - def render(action = nil, options = {}) - options = _normalize_options(action, options) + def render(action = nil, options = {}, &blk) + options = _normalize_options(action, options, &blk) super(options) end - def render_to_string(action = nil, options = {}) - options = _normalize_options(action, options) + def render_to_string(action = nil, options = {}, &blk) + options = _normalize_options(action, options, &blk) super(options) end diff --git a/actionpack/lib/action_controller/new_base/render_options.rb b/actionpack/lib/action_controller/new_base/render_options.rb index aa6593b957..1df23deee7 100644 --- a/actionpack/lib/action_controller/new_base/render_options.rb +++ b/actionpack/lib/action_controller/new_base/render_options.rb @@ -71,5 +71,16 @@ module ActionController self.response_body = xml.respond_to?(:to_xml) ? xml.to_xml : xml end end + + module Rjs + include RenderOption + register_renderer :update + + def _render_update(proc, options) + generator = ActionView::Helpers::PrototypeHelper::JavaScriptGenerator.new(_action_view, &proc) + response.content_type = Mime::JS + self.response_body = generator.to_s + end + end end end
\ No newline at end of file |