Skip to content

Commit

Permalink
Helper#icon prepends fa- to given fa class string
Browse files Browse the repository at this point in the history
ex: icon('flag 2x') rather than icon('flag', class: 'fa-2x')
  • Loading branch information
nnattawat committed Nov 12, 2015
1 parent 8220839 commit 2132ef6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ icon('flag')
# => <i class="fa fa-flag"></i>
```

```ruby
icon('flag 2x')
# => <i class="fa fa-flag fa-2x"></i>
```

```ruby
icon('flag', class: 'strong')
# => <i class="fa fa-flag strong"></i>
Expand Down
3 changes: 2 additions & 1 deletion lib/font_awesome/sass/rails/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 2132ef6

Please sign in to comment.