Permalink
Browse files

Render attributes

  • Loading branch information...
1 parent 211c097 commit 1787e66ab6708630d98237f785a792e943ddf0ee Joe Fiorini committed Jan 15, 2010
Showing with 7 additions and 2 deletions.
  1. +2 −2 lib/totally_tabular/html_helper.rb
  2. +5 −0 spec/lib/totally_tabular/html_helper_spec.rb
@@ -9,8 +9,8 @@ def tag(tag, content="", attributes={})
"<input>"
when /^\w+$/
if attributes.any?
- css_class = attributes[:class]
- attr_string = ' class="%s"' % css_class
+ attr_string =
+ attr_string = ' %s' % attributes.map { |attr| '%s="%s"' % attr }.join(" ")
end
"<%s%s>%s</%s>" % [tag, attr_string, content, tag]
else
@@ -40,4 +40,9 @@
it "renders with a class specified" do
@helper.tag(:strong, "blah", :class => "diddy").should =~ /class=\"diddy\"/
end
+
+ it "renders with a href attribute specified" do
+ url = "http://www.google.com"
+ @helper.tag(:a, "blah", :href => url).should =~ /href=\"#{url}\"/
+ end
end

0 comments on commit 1787e66

Please sign in to comment.