[Haml] [html2haml] Handle <div class='foo.bar'> correctly.

This commit is contained in:
Nathan Weizenbaum 2009-10-20 01:07:14 -07:00
parent 54cf0e0371
commit b02ae992c6
3 changed files with 8 additions and 1 deletions

View File

@ -96,6 +96,9 @@ including the line number and the offending character.
without spaces within the curly braces
(e.g. `%p{:foo => "bar"}` as opposed to `%p{ :foo => "bar" }`).
* IDs and classes containing `#` and `.` are now output as string attributes
(e.g. `%p{:class => "foo.bar"}`).
* Attributes are now sorted, to maintain a deterministic order.
## [2.2.7](http://github.com/nex3/haml/commit/2.2.7)

View File

@ -317,7 +317,7 @@ module Haml
end
def static_attribute?(name, options)
attributes[name] and !dynamic_attribute?(name, options)
attributes[name] && attributes[name] =~ /^[-:\w]+$/ && !dynamic_attribute?(name, options)
end
def dynamic_attribute?(name, options)

View File

@ -27,6 +27,10 @@ class Html2HamlTest < Test::Unit::TestCase
render('<meta http-equiv="Content-Type" content="text/html" />'))
end
def test_class_with_dot
assert_equal('%div{:class => "foo.bar"}', render("<div class='foo.bar'></div>"))
end
def test_interpolation
assert_equal('Foo \#{bar} baz', render('Foo #{bar} baz'))
end