Skip to content

Commit

Permalink
adding support for glyph helper custom classes
Browse files Browse the repository at this point in the history
  • Loading branch information
mschneider85 committed Jan 14, 2017
1 parent d3776dd commit 07e9ac2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,8 @@ Glyph:
<%= glyph(:pencil) %> <i class="icon-pencil"></i>
<%= glyph(:pencil, {tag: :span}) %> <span class="icon-pencil"></span>
<%= glyph(:pencil, {class: 'foo'}) %> <i class="icon-pencil foo"></i>
```

### I18n Internationalization Support
Expand All @@ -616,7 +618,7 @@ Please see CONTRIBUTERS.md for contributors list


## About Me
Senior Software Developer @INGBank
Senior Software Developer @INGBank
Istanbul / Turkey


Expand Down
7 changes: 4 additions & 3 deletions app/helpers/glyph_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ module GlyphHelper
# glyph(:lock, {tag: :span})
# # => <span class="icon-lock"></span>
def glyph(*names)
options = (names.last.kind_of?(Hash)) ? names.pop : {}
names.map! { |name| name.to_s.gsub('_','-') }
options = names.last.kind_of?(Hash) ? names.pop : {}
names.map! { |name| name.to_s.tr('_', '-') }
names.map! do |name|
name =~ /pull-(?:left|right)/ ? name : "glyphicon glyphicon-#{name}"
end
options[:tag] = options[:tag] ||= :i
content_tag options[:tag], nil, :class => names
names.push options[:class]
content_tag options[:tag], nil, class: names
end
end

0 comments on commit 07e9ac2

Please sign in to comment.