From 2132ef6462566a33d95e312729575a85746a00ff Mon Sep 17 00:00:00 2001 From: Nattawat Nonsung Date: Thu, 12 Nov 2015 13:03:53 +1100 Subject: [PATCH 1/2] Helper#icon prepends fa- to given fa class string ex: icon('flag 2x') rather than icon('flag', class: 'fa-2x') --- README.md | 5 +++++ lib/font_awesome/sass/rails/helpers.rb | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index acd893cf..a3ae44dd 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,11 @@ icon('flag') # => ``` +```ruby +icon('flag 2x') +# => +``` + ```ruby icon('flag', class: 'strong') # => diff --git a/lib/font_awesome/sass/rails/helpers.rb b/lib/font_awesome/sass/rails/helpers.rb index abc2f271..7d6fa08b 100644 --- a/lib/font_awesome/sass/rails/helpers.rb +++ b/lib/font_awesome/sass/rails/helpers.rb @@ -5,7 +5,8 @@ module ViewHelpers def icon(icon, text = nil, html_options = {}) text, html_options = nil, text if text.is_a?(Hash) - content_class = "fa fa-#{icon}" + icons = icon.split(" ").map { |icon| "fa-#{icon}" }.join(" ") + content_class = "fa #{icons}" content_class << " #{html_options[:class]}" if html_options.key?(:class) html_options[:class] = content_class From 825bbacc19e56116176e0b9a35d2da75690864ec Mon Sep 17 00:00:00 2001 From: Nattawat Nonsung Date: Thu, 12 Nov 2015 13:03:53 +1100 Subject: [PATCH 2/2] Helper#icon prepends fa- to multiple classes, to get now we can do: - icon('flag 2x') - icon([:flag, '2x']) --- lib/font_awesome/sass/rails/helpers.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/font_awesome/sass/rails/helpers.rb b/lib/font_awesome/sass/rails/helpers.rb index 7d6fa08b..b6d2381a 100644 --- a/lib/font_awesome/sass/rails/helpers.rb +++ b/lib/font_awesome/sass/rails/helpers.rb @@ -5,8 +5,8 @@ module ViewHelpers def icon(icon, text = nil, html_options = {}) text, html_options = nil, text if text.is_a?(Hash) - icons = icon.split(" ").map { |icon| "fa-#{icon}" }.join(" ") - content_class = "fa #{icons}" + icons = icon.is_a?(Array) ? icon : icon.to_s.split(" ") + content_class = "fa #{icons.map { |i| "fa-#{i}" }.join(' ')}" content_class << " #{html_options[:class]}" if html_options.key?(:class) html_options[:class] = content_class