lib/sinatra/static_assets.rb in sinatra-static-assets-1.0.3 vs lib/sinatra/static_assets.rb in sinatra-static-assets-1.0.4

- old
+ new

@@ -36,9 +36,22 @@ def link_to(desc, url, options = {}) tag("a", options.merge(:href => url_for(url))) do desc end end + + def link_favicon_tag(source = nil, options = {}) + source = "favicon.ico" if source.nil? or source.empty? + unless settings.xhtml + # html5 style like <link rel="icon" href="http://example.com/myicon.ico" /> + options[:rel] = options[:rel] || "icon" + else + # xhtml style like <link rel="shortcut icon" href="http://example.com/myicon.ico" /> + options[:rel] = "shortcut icon" + end + options[:href] = url_for(source) + tag("link", options) + end private def url_for(addr, absolute = false) uri(addr, absolute == :full ? true : false, true)