diff options
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/abstract_controller.rb | 1 | ||||
-rw-r--r-- | actionpack/lib/abstract_controller/rendering.rb | 50 | ||||
-rw-r--r-- | actionpack/lib/action_controller/base.rb | 6 |
3 files changed, 56 insertions, 1 deletions
diff --git a/actionpack/lib/abstract_controller.rb b/actionpack/lib/abstract_controller.rb index 909b438a41..52f16b7bec 100644 --- a/actionpack/lib/abstract_controller.rb +++ b/actionpack/lib/abstract_controller.rb @@ -13,6 +13,7 @@ module AbstractController autoload :DoubleRenderError, "abstract_controller/rendering.rb" autoload :Helpers autoload :Logger + autoload :Rendering autoload :Translation autoload :AssetPaths autoload :UrlFor diff --git a/actionpack/lib/abstract_controller/rendering.rb b/actionpack/lib/abstract_controller/rendering.rb index 8997207550..6e5b172203 100644 --- a/actionpack/lib/abstract_controller/rendering.rb +++ b/actionpack/lib/abstract_controller/rendering.rb @@ -6,4 +6,54 @@ module AbstractController super(message || DEFAULT_MESSAGE) end end + + module Rendering + # Raw rendering of a template to a string. + # + # It is similar to render, except that it does not + # set the response_body and it should be guaranteed + # to always return a string. + # + # If a component extends the semantics of response_body + # (as Action Controller extends it to be anything that + # responds to the method each), this method needs to be + # overridden in order to still return a string. + # :api: plugin + def render_to_string(*args, &block) + end + + # Raw rendering of a template. + # :api: plugin + def render_to_body(options = {}) + end + + def render(*args, &block) + end + + # This method should return a hash with assigns. + # You can overwrite this configuration per controller. + # :api: public + def view_assigns + {} + end + + # Normalize args by converting render "foo" to render :action => "foo" and + # render "foo/bar" to render :file => "foo/bar". + # :api: plugin + def _normalize_args(action=nil, options={}) + options + end + + # Normalize options. + # :api: plugin + def _normalize_options(options) + options + end + + # Process extra options. + # :api: plugin + def _process_options(options) + options + end + end end diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index ebb7cc2a64..82a7366f6b 100644 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -161,7 +161,11 @@ module ActionController # render action: "overthere" # won't be called if monkeys is nil # end # - class Base < Metal + metal = Class.new(Metal) do + include AbstractController::Rendering + end + + class Base < metal abstract! # We document the request and response methods here because albeit they are |