aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/renderer.rb
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2008-07-03 13:06:00 -0500
committerJoshua Peek <josh@joshpeek.com>2008-07-03 13:06:00 -0500
commit8a442e0d57fabedcaf3ded836cfc12f7067ead68 (patch)
tree3ab64f7ec0bda906882531af8a76a54ef83ae282 /actionpack/lib/action_view/renderer.rb
parent7d5c8505f528f195433693d5074a00f7635955b2 (diff)
downloadrails-8a442e0d57fabedcaf3ded836cfc12f7067ead68.tar.gz
rails-8a442e0d57fabedcaf3ded836cfc12f7067ead68.tar.bz2
rails-8a442e0d57fabedcaf3ded836cfc12f7067ead68.zip
Extracted Template rendering logic into Renderer module
Diffstat (limited to 'actionpack/lib/action_view/renderer.rb')
-rw-r--r--actionpack/lib/action_view/renderer.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/renderer.rb b/actionpack/lib/action_view/renderer.rb
new file mode 100644
index 0000000000..e6c64d2749
--- /dev/null
+++ b/actionpack/lib/action_view/renderer.rb
@@ -0,0 +1,29 @@
+module ActionView
+ module Renderer
+ # TODO: Local assigns should not be tied to template instance
+ attr_accessor :locals
+
+ # TODO: These readers should be private
+ attr_reader :filename, :source, :handler, :method_key, :method
+
+ def render
+ prepare!
+ @handler.render(self)
+ end
+
+ private
+ def prepare!
+ unless @prepared
+ @view.send(:evaluate_assigns)
+ @view.current_render_extension = @extension
+
+ if @handler.compilable?
+ @handler.compile_template(self) # compile the given template, if necessary
+ @method = @view.method_names[method_key] # Set the method name for this template and run it
+ end
+
+ @prepared = true
+ end
+ end
+ end
+end