Permalink
Browse files

Sinatra adapter no longer renders attributes with nil values as attri…

…butes with empty strings in the output, instead \

electing not to render the attribute at all. Fixes issue #93. Thanks to @revdan for pointing this out.
  • Loading branch information...
mjtko committed Mar 24, 2012
1 parent 73b997a commit c956410b616641f59b2f0c26d540ef3445ea8706
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/simple_navigation/adapters/sinatra.rb
@@ -43,11 +43,11 @@ def current_page?(url)
end
def link_to(name, url, options={})
- "<a href='#{url}' #{to_attributes(options)}>#{name}</a>"
+ "<a href='#{url}'#{to_attributes(options)}>#{name}</a>"
end
def content_tag(type, content, options={})
- "<#{type} #{to_attributes(options)}>#{content}</#{type}>"
+ "<#{type}#{to_attributes(options)}>#{content}</#{type}>"
end
protected
@@ -61,7 +61,7 @@ def self.sinatra_environment
end
def to_attributes(options)
- options.map {|k, v| "#{k}='#{v}'"}.join(' ')
+ options.map {|k, v| v.nil? ? '' : " #{k}='#{v}'"}.join
end
end

0 comments on commit c956410

Please sign in to comment.