aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/abstract_controller/rendering.rb
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@plataformatec.com.br>2013-09-09 12:05:09 -0300
committerJosé Valim <jose.valim@plataformatec.com.br>2013-09-09 12:33:53 -0300
commita41669563b960d604068013a5b808476391b1cb9 (patch)
tree7dc3d804f06d05de471e34ef8ff3e63618fe2d3e /actionpack/lib/abstract_controller/rendering.rb
parentff8fac614f04f9cc7bc4ce78f3b9a758814cd0ab (diff)
downloadrails-a41669563b960d604068013a5b808476391b1cb9.tar.gz
rails-a41669563b960d604068013a5b808476391b1cb9.tar.bz2
rails-a41669563b960d604068013a5b808476391b1cb9.zip
Remove BasicRendering and remove template functionality from AbsC::Rendering
Diffstat (limited to 'actionpack/lib/abstract_controller/rendering.rb')
-rw-r--r--actionpack/lib/abstract_controller/rendering.rb43
1 files changed, 12 insertions, 31 deletions
diff --git a/actionpack/lib/abstract_controller/rendering.rb b/actionpack/lib/abstract_controller/rendering.rb
index 4596aad46c..575b9807d0 100644
--- a/actionpack/lib/abstract_controller/rendering.rb
+++ b/actionpack/lib/abstract_controller/rendering.rb
@@ -10,6 +10,14 @@ module AbstractController
end
end
+ class UnsupportedOperationError < Error
+ DEFAULT_MESSAGE = "Unsupported render operation. BasicRendering supports only :text and :nothing options. For more, you need to include ActionView."
+
+ def initialize
+ super DEFAULT_MESSAGE
+ end
+ end
+
module Rendering
extend ActiveSupport::Concern
@@ -22,6 +30,8 @@ module AbstractController
# sticks the result in self.response_body.
# :api: public
def render(*args, &block)
+ options = _normalize_render(*args, &block)
+ self.response_body = render_to_body(options)
end
# Raw rendering of a template to a string.
@@ -40,11 +50,10 @@ module AbstractController
render_to_body(options)
end
- # Raw rendering of a template.
+ # Performs the actual template rendering.
# :api: public
def render_to_body(options = {})
- _process_options(options)
- _render_template(options)
+ raise UnsupportedOperationError
end
# Return Content-Type of rendered content
@@ -97,32 +106,4 @@ module AbstractController
options
end
end
-
- # Basic rendering implements the most minimal rendering layer.
- # It only supports rendering :text and :nothing. Passing any other option will
- # result in `UnsupportedOperationError` exception. For more functionality like
- # different formats, layouts etc. you should use `ActionView` gem.
- module BasicRendering
- extend ActiveSupport::Concern
-
- # Render text or nothing (empty string) to response_body
- # :api: public
- def render(*args, &block)
- super(*args, &block)
- opts = args.first
- if opts.has_key?(:text) && opts[:text].present?
- self.response_body = opts[:text]
- elsif opts.has_key?(:nothing) && opts[:nothing]
- self.response_body = " "
- else
- raise UnsupportedOperationError
- end
- end
-
- class UnsupportedOperationError < StandardError
- def initialize
- super "Unsupported render operation. BasicRendering supports only :text and :nothing options. For more, you need to include ActionView."
- end
- end
- end
end