From 6d91d9fb8348c6881c096080e7d5dc685b276ddc Mon Sep 17 00:00:00 2001 From: Stephen Bannasch Date: Fri, 9 Sep 2011 00:22:09 -0400 Subject: [PATCH] force :xhtml if options[:mime_type] == 'text/xml' If options[:mime_type] is defined and the value == 'text/xml' then an instanced Haml::Engine will always use :xhtml --- lib/haml/engine.rb | 2 ++ test/engine_test.rb | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/lib/haml/engine.rb b/lib/haml/engine.rb index 512c7b10..ce109fc1 100644 --- a/lib/haml/engine.rb +++ b/lib/haml/engine.rb @@ -101,6 +101,8 @@ module Haml @options.merge! options.reject {|k, v| v.nil?} @index = 0 + @options[:format] = :xhtml if @options[:mime_type] == 'text/xml' + unless [:xhtml, :html4, :html5].include?(@options[:format]) raise Haml::Error, "Invalid output format #{@options[:format].inspect}" end diff --git a/test/engine_test.rb b/test/engine_test.rb index 2595b74b..dd13c7bd 100644 --- a/test/engine_test.rb +++ b/test/engine_test.rb @@ -1528,6 +1528,36 @@ HAML render("%div{data_val, :data => {:foo => 'blip', :brat => 'wurst'}}")) end + def test_xml_doc_using_html5_format_and_mime_type + assert_equal(< :html5, :mime_type => 'text/xml' })) + + + +
+
+XML +!!! XML +%root + %element/ + %hr +HAML + end + + def test_xml_doc_using_html4_format_and_mime_type + assert_equal(< :html4, :mime_type => 'text/xml' })) + + + +
+
+XML +!!! XML +%root + %element/ + %hr +HAML + end + # New attributes def test_basic_new_attributes