method
compile_template
v2.1.0 -
Show latest stable
- Class:
ActionView::TemplateHandlers::Compilable
compile_template(template)public
Compile and evaluate the template’s code
# File actionpack/lib/action_view/template_handlers/compilable.rb, line 33
def compile_template(template)
return unless compile_template?(template)
render_symbol = assign_method_name(template)
render_source = create_template_source(template, render_symbol)
line_offset = self.template_args[render_symbol].size + self.line_offset
begin
file_name = template.filename || 'compiled-template'
ActionView::Base::CompiledTemplates.module_eval(render_source, file_name, -line_offset)
rescue Exception => e # errors from template code
if @view.logger
@view.logger.debug "ERROR: compiling #{render_symbol} RAISED #{e}"
@view.logger.debug "Function body: #{render_source}"
@view.logger.debug "Backtrace: #{e.backtrace.join("\n")}"
end
raise ActionView::TemplateError.new(template, @view.assigns, e)
end
self.compile_time[render_symbol] = Time.now
# logger.debug "Compiled template #{file_name || template}\n ==> #{render_symbol}" if logger
end Related methods
- Instance methods
- compile_template
- render
- Class methods
- included
- Private methods
-
assign_method_name -
compile_template? -
compiled_method_name -
compiled_method_name_file_path_segment -
create_template_source -
supports_local_assigns? -
template_changed_since?