Method: XHTML#header

Defined in:
lib/xhtml.rb

#header(options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/xhtml.rb', line 8

def header (options = {})
    unless not options[:charset].nil?
        options[:charset] = 'UTF-8'
    end
    unless not options[:content].nil?
        options[:content] = 'text/html;charset=UTF-8'
    end
	@xhtml_cgi_output << "Content-Type: text.html\n\n"
    @xhtml_cgi_output << '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"'
    @xhtml_cgi_output << "\n"
    @xhtml_cgi_output << '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
    @xhtml_cgi_output << "\n<html xmlns='http://www.w3.org/1999/xhtml'>\n"
    @xhtml_cgi_output << "  <head>\n"
    unless options[:base].nil?
        @xhtml_cgi_output << "    <base href='#{options[:base]}' />\n"
    end
    unless options[:style].nil?
        options[:style].each do |x|
            @xhtml_cgi_output << "    <link rel='stylesheet' type='text/css' href='#{x}' />\n"
        end
    end
    unless options[:script].nil?
        options[:script].each do |x|
            @xhtml_cgi_output << "    <script src='#{x}' type='text/javascript'></script>\n"
        end
    end
    unless options[:contact].nil?
        @xhtml_cgi_output << "    <link rev='made' href='mailto:#{options[:contact]}' />\n"
    end
    unless options[:keywords].nil?
        @xhtml_cgi_output << "    <meta name='keywords' content='#{options[:keywords]}' />\n"
    end
    unless options[:author].nil?
        @xhtml_cgi_output << "    <meta name='author' content='#{options[:author]}' />\n"
    end
    unless options[:description].nil?
        @xhtml_cgi_output << "    <meta name='description' content='#{options[:description]}' />\n"
    end
    @xhtml_cgi_output << "    <meta name='charset' content='#{options[:charset]}' />\n"
    @xhtml_cgi_output << "    <meta http-equiv='Content-type' content='#{options[:content]}' />\n"
    @xhtml_cgi_output << "  </head>\n"
end