[Haml] Raise an error when commas are omitted in static attributes.
This commit is contained in:
parent
851eee821e
commit
f1a6cc9eec
|
@ -11,6 +11,9 @@
|
|||
* Don't crash when the `__FILE__` constant of a Ruby file is a relative path,
|
||||
as apparently happens sometimes in TextMate
|
||||
(thanks to [Karl Varga](http://github.com/kjvarga).
|
||||
|
||||
* 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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -54,6 +54,7 @@ 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,
|
||||
|
||||
# Regression tests
|
||||
"- raise 'foo'\n\n\n\nbar" => ["foo", 1],
|
||||
|
@ -737,7 +738,12 @@ HAML
|
|||
line_no ||= key.split("\n").length
|
||||
line_reported = err.backtrace[0].gsub(/\(.+\):/, '').to_i
|
||||
|
||||
assert_equal(expected_message, err.message, "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_equal(line_no, line_reported, "Line: #{key}")
|
||||
else
|
||||
assert(false, "Exception not raised for\n#{key}")
|
||||
|
|
Loading…
Reference in New Issue