Skip to content

Commit

Permalink
Add favicon helper
Browse files Browse the repository at this point in the history
  • Loading branch information
deepj authored and jodosha committed Dec 13, 2015
1 parent dfc52ea commit ab74927
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion asset_tag_helpers.rb
Expand Up @@ -37,6 +37,26 @@ def image(source, options = {})
html.img(options)
end

# Creates a link tag for a favicon.
#
# @since x.x.x
# @api public
#
# @example Basic usage
# <%= favicon %>
# # => <link href="/assets/favicon.ico" rel="shortcut icon" type="image/x-icon">
#
# @example HTML attributes
# <%= favicon('favicon.png', rel: 'icon', type: 'image/png')
# # => <link rel="icon" type="image/png" href="/assets/favicon.png">
def favicon(source = 'favicon.ico', options = {})
options[:href] = asset_path(source)
options[:rel] ||= 'shortcut icon'
options[:type] ||= 'image/x-icon'

html.link(options)
end

def asset_path(source)
"/assets/#{source}" # To be implemented
end
Expand Down Expand Up @@ -105,4 +125,4 @@ def video(src = nil, options = {}, &blk)
end
end
end
end
end

0 comments on commit ab74927

Please sign in to comment.