class Hamlit::Compiler::DoctypeCompiler
Public Class Methods
new(options = {})
click to toggle source
# File lib/hamlit/compiler/doctype_compiler.rb, line 4 def initialize(options = {}) @format = options[:format] end
Public Instance Methods
compile(node)
click to toggle source
# File lib/hamlit/compiler/doctype_compiler.rb, line 8 def compile(node) case node.value[:type] when 'xml' xml_doctype when '' html_doctype(node) else [:html, :doctype, node.value[:type]] end end
Private Instance Methods
html_doctype(node)
click to toggle source
# File lib/hamlit/compiler/doctype_compiler.rb, line 21 def html_doctype(node) version = node.value[:version] || :transitional case @format when :xhtml [:html, :doctype, version] when :html4 [:html, :doctype, :transitional] when :html5 [:html, :doctype, :html] else [:html, :doctype, @format] end end
xml_doctype()
click to toggle source
# File lib/hamlit/compiler/doctype_compiler.rb, line 35 def xml_doctype case @format when :xhtml [:static, "<?xml version='1.0' encoding='utf-8' ?>\n"] else [:multi] end end