diff --git a/lib/temple/html/fast.rb b/lib/temple/html/fast.rb
index c61bb2c..fa84350 100644
--- a/lib/temple/html/fast.rb
+++ b/lib/temple/html/fast.rb
@@ -51,6 +51,7 @@ def html4?
end
def on_html_doctype(type)
+ type = type.to_s
trailing_newlines = type[/(\A|[^\r])(\n+)\Z/, 2].to_s
text = type.downcase.strip