diff --git a/Rakefile b/Rakefile index d7a03dd1..1a0010ff 100644 --- a/Rakefile +++ b/Rakefile @@ -25,6 +25,7 @@ Rake::TestTask.new do |t| t.libs << 'lib' test_files = FileList['test/**/*_test.rb'] test_files.exclude('test/rails/*') + test_files.exclude('test/haml/spec/*') t.test_files = test_files t.verbose = true end @@ -163,7 +164,7 @@ def mode_unchanged?(mode, version) mode_version = File.read("extra/#{mode}-mode.el").scan(/^;; Version: (.*)$/).first.first return false if mode_version == version return mode_version unless changed_since?(mode_version, "extra/#{mode}-mode.el") - raise "#{mode}-mode.el version is #{haml_mode_version.inspect}, but it has changed as of #{version.inspect}" + raise "#{mode}-mode.el version is #{version.inspect}, but it has changed as of #{version.inspect}" return false end diff --git a/VERSION b/VERSION index 21bb5e15..bda8fbec 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.2.5 +2.2.6 diff --git a/doc-src/HAML_CHANGELOG.md b/doc-src/HAML_CHANGELOG.md index 6cbb7cf5..cd00b3eb 100644 --- a/doc-src/HAML_CHANGELOG.md +++ b/doc-src/HAML_CHANGELOG.md @@ -3,7 +3,7 @@ * Table of contents {:toc} -## 2.2.6 (Unreleased) +## [2.2.6](http://github.com/nex3/haml/commit/2.2.6) * Made the error message when unable to load a dependency for html2haml respect the `--trace` option. @@ -14,6 +14,9 @@ * Add "Sass" to the `--version` string for the executables. +* Raise an exception when commas are omitted in static attributes + (e.g. `%p{:foo => "bar" :baz => "bang"}`). + ## [2.2.5](http://github.com/nex3/haml/commit/2.2.5) * Got rid of trailing whitespace produced when opening a conditional comment diff --git a/doc-src/SASS_CHANGELOG.md b/doc-src/SASS_CHANGELOG.md index ffcaaf8a..7f11f84d 100644 --- a/doc-src/SASS_CHANGELOG.md +++ b/doc-src/SASS_CHANGELOG.md @@ -3,7 +3,7 @@ * Table of contents {:toc} -## 2.2.6 (Unreleased) +## [2.2.6](http://github.com/nex3/haml/commit/2.2.6) * Don't crash when the `__FILE__` constant of a Ruby file is a relative path, as apparently happens sometimes in TextMate diff --git a/extra/haml-mode.el b/extra/haml-mode.el index d6bbaa30..d759d0ff 100644 --- a/extra/haml-mode.el +++ b/extra/haml-mode.el @@ -4,7 +4,7 @@ ;; Author: Nathan Weizenbaum ;; URL: http://github.com/nex3/haml/tree/master -;; Version: 2.2.5 +;; Version: 2.2.6 ;; Created: 2007-03-08 ;; By: Nathan Weizenbaum ;; Keywords: markup, language, html diff --git a/extra/sass-mode.el b/extra/sass-mode.el index 50c17d88..95750631 100644 --- a/extra/sass-mode.el +++ b/extra/sass-mode.el @@ -4,7 +4,7 @@ ;; Author: Nathan Weizenbaum ;; URL: http://github.com/nex3/haml/tree/master -;; Version: 2.2.5 +;; Version: 2.2.6 ;; Created: 2007-03-15 ;; By: Nathan Weizenbaum ;; Keywords: markup, language, css diff --git a/lib/haml/precompiler.rb b/lib/haml/precompiler.rb index 4ce32bce..e3df4eef 100644 --- a/lib/haml/precompiler.rb +++ b/lib/haml/precompiler.rb @@ -465,8 +465,8 @@ END return unless key = scanner.scan(LITERAL_VALUE_REGEX) return unless scanner.scan(/\s*=>\s*/) return unless value = scanner.scan(LITERAL_VALUE_REGEX) + return unless scanner.scan(/\s*(?:,|$)\s*/) attributes[eval(key).to_s] = eval(value).to_s - scanner.scan(/[,\s]*/) end text.count("\n").times { newline } attributes diff --git a/test/haml/engine_test.rb b/test/haml/engine_test.rb index 5c5b9ecf..d61eb430 100644 --- a/test/haml/engine_test.rb +++ b/test/haml/engine_test.rb @@ -54,6 +54,12 @@ class EngineTest < Test::Unit::TestCase "%p(foo 'bar')" => "Invalid attribute list: \"(foo 'bar')\".", "%p(foo 'bar'\nbaz='bang')" => ["Invalid attribute list: \"(foo 'bar'\".", 1], "%p(foo='bar'\nbaz 'bang'\nbip='bop')" => ["Invalid attribute list: \"(foo='bar' baz 'bang'\".", 2], + "%p{:foo => 'bar' :bar => 'baz'}" => :compile, + "%p{:foo => }" => :compile, + "%p{=> 'bar'}" => :compile, + "%p{:foo => 'bar}" => :compile, + "%p{'foo => 'bar'}" => :compile, + "%p{:foo => 'bar\"}" => :compile, # Regression tests "- raise 'foo'\n\n\n\nbar" => ["foo", 1], @@ -727,18 +733,22 @@ HAML assert_equal("\nc\n", render("%a{'b' => 1 + 1}/\n= 'c'\n")) end - def test_exceptions - EXCEPTION_MAP.each do |key, value| + EXCEPTION_MAP.each do |key, value| + define_method("test_exception (#{key.inspect})") do begin - render(key, :filename => "(exception test for #{key.inspect})") + render(key, :filename => __FILE__) rescue Exception => err value = [value] unless value.is_a?(Array) expected_message, line_no = value line_no ||= key.split("\n").length - line_reported = err.backtrace[0].gsub(/\(.+\):/, '').to_i - assert_equal(expected_message, err.message, "Line: #{key}") - assert_equal(line_no, line_reported, "Line: #{key}") + if expected_message == :compile + assert_match(/^compile error\n/, err.message, "Line: #{key}") + else + assert_equal(expected_message, err.message, "Line: #{key}") + end + + assert_match(/^#{Regexp.escape(__FILE__)}:#{line_no}/, err.backtrace[0], "Line: #{key}") else assert(false, "Exception not raised for\n#{key}") end