Class Hpricot::DocType
In: lib/haml/html.rb
Parent: Object
Haml::HTML::Node BaseEle Comment XMLDecl Doc CData Elem DocType lib/haml/html.rb Node Hpricot dot/m_10_0.png

@see Hpricot

Methods

to_haml  

Public Instance methods

@see Haml::HTML::Node#to_haml

[Source]

     # File lib/haml/html.rb, line 134
134:       def to_haml(tabs, options)
135:         attrs = public_id.nil? ? ["", "", ""] :
136:           public_id.scan(/DTD\s+([^\s]+)\s*([^\s]*)\s*([^\s]*)\s*\/\//)[0]
137:         if attrs == nil
138:           raise Exception.new("Invalid doctype")
139:         end
140: 
141:         type, version, strictness = attrs.map { |a| a.downcase }
142:         if type == "html"
143:           version = ""
144:           strictness = "strict" if strictness == ""
145:         end
146: 
147:         if version == "1.0" || version.empty?
148:           version = nil
149:         end
150: 
151:         if strictness == 'transitional' || strictness.empty?
152:           strictness = nil
153:         end
154: 
155:         version = " #{version.capitalize}" if version
156:         strictness = " #{strictness.capitalize}" if strictness
157: 
158:         "#{tabulate(tabs)}!!!#{version}#{strictness}\n"
159:       end

[Validate]