A convenience utility class for rendering our error pages.
# File lib/phusion_passenger/html_template.rb, line 33 33: def initialize(template_name, options = {}) 34: @buffer = '' 35: @template = ERB.new(File.read("#{TEMPLATE_DIR}/#{template_name}.html.erb"), 36: nil, nil, '@buffer') 37: options.each_pair do |name, value| 38: self[name] = value 39: end 40: end
# File lib/phusion_passenger/html_template.rb, line 75 75: def backtrace_html_for(error) 76: html = %{ 77: <table class="backtrace"> 78: <tr class="headers"> 79: <th>#</th> 80: <th>File</th> 81: <th>Line</th> 82: <th>Location</th> 83: </tr> 84: } 85: in_passenger = false 86: error.backtrace.each_with_index do |item, i| 87: filename, line, location = item.split(':', 3) 88: in_passenger ||= starts_with(filename, PASSENGER_FILE_PREFIX) 89: class_names = in_passenger ? "passenger" : "framework" 90: class_names << ((i & 1 == 0) ? " uneven" : " even") 91: html << %{ 92: <tr class="backtrace_line #{class_names}"> 93: <td class="index">#{i}</td> 94: <td class="filename">#{filename}</td> 95: <td class="line">#{line}</td> 96: <td class="location">#{location}</td> 97: </tr> 98: } 99: end 100: html << "</table>\n" 101: return html 102: end
# File lib/phusion_passenger/html_template.rb, line 54 54: def get_binding 55: return binding 56: end
# File lib/phusion_passenger/html_template.rb, line 71 71: def include(filename) 72: return File.read("#{TEMPLATE_DIR}/#{filename}") 73: end
# File lib/phusion_passenger/html_template.rb, line 58 58: def layout(template_name, options = {}) 59: options.each_pair do |name, value| 60: self[name] = value 61: end 62: layout_template = ERB.new(File.read("#{TEMPLATE_DIR}/#{template_name}.html.erb")) 63: b = get_binding do 64: old_size = @buffer.size 65: yield 66: @buffer.slice!(old_size .. @buffer.size) 67: end 68: @buffer << layout_template.result(b) 69: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.