[Haml] Fixed CSS id concatenation when a numeric id is given as an attribute.

This commit is contained in:
Nathan Weizenbaum 2009-09-18 01:14:53 -07:00
parent e222875cb0
commit 3a70a87785
3 changed files with 9 additions and 1 deletions

View File

@ -8,6 +8,9 @@
* Got rid of trailing whitespace produced when opening a conditional comment
(thanks to [Norman Clarke](http://blog.njclarke.com/)).
* Fixed CSS id concatenation when a numeric id is given as an attribute.
(thanks to [Norman Clarke](http://blog.njclarke.com/)).
## [2.2.4](http://github.com/nex3/haml/commit/2.2.4)
* Allow `end` to be used for silent script when it's followed by code.

View File

@ -245,7 +245,7 @@ RUBY
# @return [Hash<String, String>] `to`, after being merged
def self.merge_attrs(to, from)
if to['id'] && from['id']
to['id'] << '_' << from.delete('id')
to['id'] << '_' << from.delete('id').to_s
elsif to['id'] || from['id']
from['id'] ||= to['id']
end

View File

@ -107,6 +107,11 @@ class EngineTest < Test::Unit::TestCase
assert_equal("<div class='atlantis' style='ugly'></div>", render(".atlantis{:style => 'ugly'}").chomp)
end
def test_css_id_as_attribute_should_be_appended_with_underscore
assert_equal("<div id='my_id_1'></div>", render("#my_id{:id => '1'}").chomp)
assert_equal("<div id='my_id_1'></div>", render("#my_id{:id => 1}").chomp)
end
def test_ruby_code_should_work_inside_attributes
author = 'hcatlin'
assert_equal("<p class='3'>foo</p>", render("%p{:class => 1+2} foo").chomp)