aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/renderable_partial.rb
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2008-07-12 14:33:46 -0500
committerJoshua Peek <josh@joshpeek.com>2008-07-12 14:33:46 -0500
commit73b34e9f75d33dc0709d4ad36c912bdbb8977994 (patch)
treeeea7cb8c3cb428ecfacb6263f4e8f1d903a71824 /actionpack/lib/action_view/renderable_partial.rb
parent30204c4e66cea989c4ee48b52c8827c79e98f14a (diff)
downloadrails-73b34e9f75d33dc0709d4ad36c912bdbb8977994.tar.gz
rails-73b34e9f75d33dc0709d4ad36c912bdbb8977994.tar.bz2
rails-73b34e9f75d33dc0709d4ad36c912bdbb8977994.zip
Refactor template preloading. New abstractions include Renderable mixins and a refactored Template class.
Diffstat (limited to 'actionpack/lib/action_view/renderable_partial.rb')
-rw-r--r--actionpack/lib/action_view/renderable_partial.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/renderable_partial.rb b/actionpack/lib/action_view/renderable_partial.rb
new file mode 100644
index 0000000000..6a17b50a14
--- /dev/null
+++ b/actionpack/lib/action_view/renderable_partial.rb
@@ -0,0 +1,19 @@
+module ActionView
+ module RenderablePartial
+ # NOTE: The template that this mixin is beening include into is frozen
+ # So you can not set or modify any instance variables
+
+ def render(view, local_assigns = {})
+ ActionController::Base.benchmark("Rendered #{path_without_format_and_extension}", Logger::DEBUG, false) do
+ super
+ end
+ end
+
+ def render_partial(view, variable_name, object = nil, local_assigns = {}, as = nil)
+ object ||= view.controller.instance_variable_get("@#{variable_name}") if view.respond_to?(:controller)
+ local_assigns[:object] ||= local_assigns[variable_name] ||= object
+ local_assigns[as] ||= local_assigns[:object] if as
+ render_template(view, local_assigns)
+ end
+ end
+end