class ActionView::Base
def compile_template(handler, template, file_name, local_assigns)
def compile_template(handler, template, file_name, local_assigns) render_symbol = assign_method_name(handler, template, file_name) # Move begin up two lines so it captures compilation exceptions. begin render_source = create_template_source(handler, template, render_symbol, local_assigns.keys) line_offset = @@template_args[render_symbol].size + handler.line_offset file_name = 'compiled-template' if file_name.blank? CompiledTemplates.module_eval(render_source, file_name, -line_offset) rescue Exception => e # errors from template code if logger logger.debug "ERROR: compiling #{render_symbol} RAISED #{e}" logger.debug "Function body: #{render_source}" logger.debug "Backtrace: #{e.backtrace.join("\n")}" end # There's no way to tell Haml about the filename, # so we've got to insert it ourselves. e.backtrace[0].gsub!('(haml)', file_name) if e.is_a?(Haml::Error) raise ActionView::TemplateError.new(extract_base_path_from(file_name) || view_paths.first, file_name || template, @assigns, template, e) end @@compile_time[render_symbol] = Time.now # logger.debug "Compiled template #{file_name || template}\n ==> #{render_symbol}" if logger end