diff options
author | Yehuda Katz <wycats@gmail.com> | 2009-02-27 11:42:13 -0800 |
---|---|---|
committer | Yehuda Katz <wycats@gmail.com> | 2009-02-27 11:42:13 -0800 |
commit | d1157e7242d248b37546800bf7816c3035b56ce8 (patch) | |
tree | a60dd14e012ae0d7d758e4cbb3a16724c0ca9596 /actionpack/lib/action_controller | |
parent | b1f078bddfecd40cce47b7db738620f2df2219c9 (diff) | |
download | rails-d1157e7242d248b37546800bf7816c3035b56ce8.tar.gz rails-d1157e7242d248b37546800bf7816c3035b56ce8.tar.bz2 rails-d1157e7242d248b37546800bf7816c3035b56ce8.zip |
AbstractController now supports layouts and rendering
Diffstat (limited to 'actionpack/lib/action_controller')
4 files changed, 42 insertions, 10 deletions
diff --git a/actionpack/lib/action_controller/abstract/base.rb b/actionpack/lib/action_controller/abstract/base.rb index c139531956..6ff4ed8dd2 100644 --- a/actionpack/lib/action_controller/abstract/base.rb +++ b/actionpack/lib/action_controller/abstract/base.rb @@ -3,8 +3,8 @@ module AbstractController attr_internal :response_body attr_internal :response_obj - cattr_accessor :logger - + attr_internal :action_name + def self.process(action) new.process(action) end @@ -13,8 +13,9 @@ module AbstractController self.response_obj = {} end - def process(action) - send(action) + def process(action_name) + @_action_name = action_name + send(action_name) self.response_obj[:body] = self.response_body self end diff --git a/actionpack/lib/action_controller/abstract/layouts.rb b/actionpack/lib/action_controller/abstract/layouts.rb new file mode 100644 index 0000000000..c8d6e77fce --- /dev/null +++ b/actionpack/lib/action_controller/abstract/layouts.rb @@ -0,0 +1,10 @@ +module AbstractController + module Layouts + def _render_template(tmp) + _action_view._render_template_with_layout(tmp, _layout) + end + + def _layout + end + end +end
\ No newline at end of file diff --git a/actionpack/lib/action_controller/abstract/logger.rb b/actionpack/lib/action_controller/abstract/logger.rb new file mode 100644 index 0000000000..846d8ad040 --- /dev/null +++ b/actionpack/lib/action_controller/abstract/logger.rb @@ -0,0 +1,7 @@ +module AbstractController + module Logger + def self.included(klass) + klass.cattr_accessor :logger + end + end +end
\ No newline at end of file diff --git a/actionpack/lib/action_controller/abstract/renderer.rb b/actionpack/lib/action_controller/abstract/renderer.rb index 7999bc1b70..dce411be92 100644 --- a/actionpack/lib/action_controller/abstract/renderer.rb +++ b/actionpack/lib/action_controller/abstract/renderer.rb @@ -1,21 +1,35 @@ +require "action_controller/abstract/logger" + module AbstractController module Renderer def self.included(klass) - klass.extend ClassMethods - klass.extlib_inheritable_accessor :view_paths - klass.view_paths ||= ActionView::PathSet.new + klass.class_eval do + extend ClassMethods + attr_internal :formats + + extlib_inheritable_accessor :view_paths + self.view_paths ||= ActionView::PathSet.new + include AbstractController::Logger + end end def _action_view @_action_view ||= ActionView::Base.new(self.class.view_paths, {}, self) end - def render(template) - tmp = view_paths.find_by_parts(template) - self.response_body = _action_view._render_template_with_layout(tmp) + def _prefix end + def render(template = action_name) + tmp = view_paths.find_by_parts(template.to_s, formats, _prefix) + self.response_body = _render_template(tmp) + end + + def _render_template(tmp) + _action_view._render_template_with_layout(tmp) + end + module ClassMethods def append_view_path(path) self.view_paths << path |