mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
33 lines
867 B
Ruby
33 lines
867 B
Ruby
module ActionView
|
|
module Renderable
|
|
# 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
|
|
|
|
def method_name
|
|
['_run', @extension, method_name_path_segment].compact.join('_').to_sym
|
|
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
|