Method: ReportBuilder::Builder::Html#out

Defined in:
lib/reportbuilder/builder/html.rb

#outObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/reportbuilder/builder/html.rb', line 41

def out
  out= <<-HERE
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<title>#{@builder.name}</title>
#{basic_css}
  HERE
  out << @headers.join("\n")
  out << "</head><body>\n"
  out << "<h1>#{@builder.name}</h1>"
  if(@toc.size>0)                      
  out << "<div id='toc'><div class='title'>List of contents</div>\n"
    actual_level=0
    
    @toc.each do |anchor,name,level|
      
      if actual_level!=level
        if actual_level > level
          (actual_level-level).times { out << "</ul>\n"}
        else
          (level-actual_level).times { out << "<ul>\n"}
        end
      end
      
      out << "<li><a href='##{anchor}'>#{name}</a></li>\n"
      actual_level=level
    end
    actual_level.times { out << "</ul>\n"}
    out << "</div>\n"
  end
  if (@list_tables.size>0)
    out << "<div class='tot'><div class='title'>List of tables</div><ul>"
    @list_tables.each {|anchor,name|
      out << "<li><a href='#"+anchor+"'>#{name}</a></li>"
    }
    out << "</ul></div>\n"
  end

  out << @body
  out << @footers.join("\n")
  out << "</body></html>"
  out
end