aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/template.rb
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2008-03-03 04:01:35 +0000
committerMichael Koziarski <michael@koziarski.com>2008-03-03 04:01:35 +0000
commit51b6619d4e78d9948952dab4709274ab57f41206 (patch)
treebab7a4d988c9349f4d8241e38e09f30d62b0049b /actionpack/lib/action_view/template.rb
parent10d9d0b6fe023df1be0d87ca95bb739bb7eb30ba (diff)
downloadrails-51b6619d4e78d9948952dab4709274ab57f41206.tar.gz
rails-51b6619d4e78d9948952dab4709274ab57f41206.tar.bz2
rails-51b6619d4e78d9948952dab4709274ab57f41206.zip
Refactor partial rendering into a PartialTemplate class. [Pratik]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8976 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view/template.rb')
-rw-r--r--actionpack/lib/action_view/template.rb22
1 files changed, 17 insertions, 5 deletions
diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb
index a814d7b4e5..9f979e2e5d 100644
--- a/actionpack/lib/action_view/template.rb
+++ b/actionpack/lib/action_view/template.rb
@@ -2,7 +2,7 @@ module ActionView #:nodoc:
class Template #:nodoc:
attr_accessor :locals
- attr_reader :handler, :path, :source, :extension, :filename, :path_without_extension
+ attr_reader :handler, :path, :source, :extension, :filename, :path_without_extension, :method
def initialize(view, path_or_source, use_full_path, locals = {}, inline = false, inline_type = nil)
@view = view
@@ -19,6 +19,12 @@ module ActionView #:nodoc:
@extension = inline_type
end
@locals = locals || {}
+ @handler = @view.class.handler_class_for_extension(@extension).new(@view)
+ end
+
+ def render
+ prepare!
+ @handler.render(self)
end
def source
@@ -29,13 +35,19 @@ module ActionView #:nodoc:
@method_key ||= (@filename || @source)
end
- def handler
- @handler ||= @view.class.handler_class_for_extension(@extension).new(@view)
- end
-
def base_path_for_exception
@finder.find_base_path_for("#{@path_without_extension}.#{@extension}") || @finder.view_paths.first
end
+
+ def prepare!
+ @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
+ end
private