Module: TopHat::HtmlHelper

Defined in:
lib/tophat/html.rb

Instance Method Summary collapse

Instance Method Details

#html_tag(options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/tophat/html.rb', line 4

def html_tag(options={})
  output = '<html'
  if options[:version]
    output << " version=\"#{options[:version]}\""
  end
  if options[:xmlns]
    if options[:xmlns].kind_of?(String)
      output << " xmlns=\"#{options[:xmlns]}\""
    elsif options[:xmlns].kind_of?(Array)
      output = options[:xmlns].inject(output) do |html, xmlns|
        if xmlns.kind_of?(Hash)
          html << " xmlns:#{xmlns[:prefix]}=\"#{xmlns[:url]}\""
        else
          html << " xmlns=\"#{xmlns}\""
        end
      end
    end
  end
  output << '>'
end