lib/rack/insight/render.rb in rack-insight-0.5.4 vs lib/rack/insight/render.rb in rack-insight-0.5.5
- old
+ new
@@ -47,29 +47,48 @@
ex.backtrace.join("\n")
end
end
end
+ #def compiled_source(filename)
+ # primary_file_path = ::File.join(::File.dirname(__FILE__), "views/#{filename}.html.erb")
+ # file = nil
+ # begin
+ # file = ::File.read(primary_file_path)
+ # rescue Errno::ENOENT
+ # end
+ # if file.nil?
+ # Rack::Insight::Config.config[:panel_load_paths].each do |load_path|
+ # begin
+ # file = ::File.read(::File.join(load_path, "#{filename}.html.erb"))
+ # break # If no error is raised then the file was read!
+ # rescue Errno::ENOENT
+ # end
+ # end
+ # end
+ # if file
+ # ::ERB.new(file, nil, "-").src
+ # else
+ # logger.fatal("Rack::Insight: Unable to find expected view template #{primary_file_path} or a #{filename}.html.erb template in rack-insight's :panel_load_paths. Configured panel load paths are: #{Rack::Insight::Config.config[:panel_load_paths].inspect}")
+ # end
+ #end
+
def compiled_source(filename)
- primary_file_path = ::File.join(::File.dirname(__FILE__), "views/#{filename}.html.erb")
+ templates = []
+ templates << ::File.join(::File.dirname(__FILE__), "views/#{filename}.html.erb")
+ templates << ::File.join(::File.join(self.class.template_root, "#{filename}.html.erb")) if self.class.respond_to?(:template_root)
file = nil
- begin
- file = ::File.read(primary_file_path)
- rescue Errno::ENOENT
- end
- if file.nil?
- Rack::Insight::Config.config[:panel_load_paths].each do |load_path|
- begin
- file = ::File.read(::File.join(load_path, "#{filename}.html.erb"))
- break # If no error is raised then the file was read!
- rescue Errno::ENOENT
- end
+ templates.each do |template_path|
+ begin
+ file = ::File.read(template_path)
+ break # If no error is raised then the file was read!
+ rescue Errno::ENOENT
end
end
if file
- return ::ERB.new(file, nil, "-").src
+ ::ERB.new(file, nil, "-").src
else
- warn "Rack::Insight: Unable to find expected view template #{primary_file_path} or a #{filename}.html.erb template in rack-insight's :panel_load_paths. Configured panel load paths are: #{Rack::Insight::Config.config[:panel_load_paths].inspect}"
+ logger.fatal("Rack::Insight: Unable to find expected view template #{filename} in any of the following locations: #{templates.inspect}")
end
end
def method_name(filename, local_assigns)
if local_assigns && local_assigns.any?