Skip to content

Commit

Permalink
#29 double tag with attributes passed through class shortcut will not…
Browse files Browse the repository at this point in the history
… render corectly
  • Loading branch information
pitr-ch committed Sep 28, 2012
1 parent ab46db6 commit 38fafe6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/hammer_builder/abstract/abstract_double_tag.rb
Expand Up @@ -19,11 +19,11 @@ def method_missing(method, *args, &block)
self.rclass.add_attributes Data::Attribute.new(method.to_sym, :string)
self.send method, *args, &block
else
self.__send__($3 == '!' ? :id : :class, $2.gsub(@_str_underscore, @_str_dash), &block)
attributes(if args.last.is_a?(Hash)
args.pop
end)
content args.first
self.__send__($3 == '!' ? :id : :class, $2.gsub(@_str_underscore, @_str_dash), &block)
end
else
super(method, *args, &block)
Expand Down
2 changes: 2 additions & 0 deletions spec/hammer_builder_spec.rb
Expand Up @@ -133,6 +133,8 @@ def quick_render &block
quick_render { div.id 'an', 'id', nil, false }.should == '<div id="an-id"></div>'

quick_render { div.an_id! :class => 'big' }.should == '<div id="an-id" class="big"></div>'
quick_render { div.an_id!(:class => 'big') { text 'content' } }.should ==
'<div id="an-id" class="big">content</div>'
quick_render { div.an_id! 'content', :class => 'big' }.should == '<div id="an-id" class="big">content</div>'
quick_render { div.an_id! 'content' }.should == '<div id="an-id">content</div>'
quick_render { hr.an_id! :class => 'big' }.should == '<hr id="an-id" class="big" />'
Expand Down

0 comments on commit 38fafe6

Please sign in to comment.