Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helper#icon prepends fa- to given fa class string #106

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(" ")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shadowing outer local variable - icon.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean?

content_class = "fa #{icons}"
content_class << " #{html_options[:class]}" if html_options.key?(:class)
html_options[:class] = content_class

Expand Down