From eac7a5f369baa225882390202cc2218aff53a6b5 Mon Sep 17 00:00:00 2001 From: Nathan Weizenbaum Date: Sun, 30 May 2010 17:32:35 -0700 Subject: [PATCH] [Haml] Default to :html5 under Rails 3. --- doc-src/HAML_CHANGELOG.md | 6 ++++++ lib/haml/template.rb | 4 ++++ test/test_helper.rb | 1 + 3 files changed, 11 insertions(+) diff --git a/doc-src/HAML_CHANGELOG.md b/doc-src/HAML_CHANGELOG.md index 197e7f5f..742dcb6e 100644 --- a/doc-src/HAML_CHANGELOG.md +++ b/doc-src/HAML_CHANGELOG.md @@ -17,6 +17,12 @@ Rather than defaulting to `"utf-8"`, it defaults to the encoding of the source document, and only falls back to `"utf-8"` if this encoding is `"us-ascii"`. +### Other Changes + +* Default to the {file:HAML_REFERENCE.md#format-option `:html5` format} + when running under Rails 3, + since it defaults to HTML5 as well. + ## 3.0.6 [Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.6). diff --git a/lib/haml/template.rb b/lib/haml/template.rb index 71fe73b8..9bb454a4 100644 --- a/lib/haml/template.rb +++ b/lib/haml/template.rb @@ -46,6 +46,10 @@ unless Haml::Util.rails_env == "development" Haml::Template.options[:ugly] ||= true end +if ActionPack::VERSION::MAJOR >= 3 + Haml::Template.options[:format] ||= :html5 +end + # Decide how we want to load Haml into Rails. # Patching was necessary for versions <= 2.0.1, # but we can make it a normal handler for higher versions. diff --git a/test/test_helper.rb b/test/test_helper.rb index 9ceb84c2..d39a47ac 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -9,6 +9,7 @@ require 'sass' require 'haml/template' Haml::Template.options[:ugly] = false +Haml::Template.options[:format] = :xhtml Sass::RAILS_LOADED = true unless defined?(Sass::RAILS_LOADED)