2015-03-23 00:57:29 +09:00
|
|
|
require 'temple/html/fast'
|
|
|
|
|
|
|
|
module Hamlit
|
|
|
|
class HTML < Temple::HTML::Fast
|
2015-03-25 01:51:40 +09:00
|
|
|
define_options :format
|
2015-03-23 01:25:29 +09:00
|
|
|
|
2015-03-23 00:57:29 +09:00
|
|
|
def initialize(opts = {})
|
|
|
|
super rewrite_format(opts)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
# Temple's warning is noisy.
|
|
|
|
def rewrite_format(options)
|
2015-03-23 01:35:06 +09:00
|
|
|
options = options.dup
|
|
|
|
options[:format] = normalize_format(options[:format]) if options[:format]
|
|
|
|
options
|
2015-03-23 00:57:29 +09:00
|
|
|
end
|
2015-03-25 01:51:40 +09:00
|
|
|
|
|
|
|
def normalize_format(format)
|
|
|
|
return :html unless format
|
|
|
|
|
|
|
|
case format
|
|
|
|
when :html4, :html5
|
|
|
|
:html
|
|
|
|
else
|
|
|
|
format
|
|
|
|
end
|
|
|
|
end
|
2015-03-23 00:57:29 +09:00
|
|
|
end
|
|
|
|
end
|