From ab749279bb59ebd654030783a7a640d03430d6e6 Mon Sep 17 00:00:00 2001 From: deepj Date: Wed, 2 Dec 2015 09:53:39 +0100 Subject: [PATCH] Add favicon helper --- asset_tag_helpers.rb | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/asset_tag_helpers.rb b/asset_tag_helpers.rb index a425fca3..4cf7524b 100644 --- a/asset_tag_helpers.rb +++ b/asset_tag_helpers.rb @@ -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 %> + # # => + # + # @example HTML attributes + # <%= favicon('favicon.png', rel: 'icon', type: 'image/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 @@ -105,4 +125,4 @@ def video(src = nil, options = {}, &blk) end end end -end \ No newline at end of file +end