Module: Cryptofont::Rails::IconHelper
- Defined in:
- app/helpers/cryptofont/rails/icon_helper.rb
Defined Under Namespace
Modules: Private
Instance Method Summary collapse
-
#cf_icon(names = 'flag', options = {}) ⇒ Object
Creates an icon tag given an icon name and possible icon modifiers.
Instance Method Details
#cf_icon(names = 'flag', options = {}) ⇒ Object
Creates an icon tag given an icon name and possible icon modifiers.
Examples
cf_icon "btc"
# => <i class="cf-btc"></i>
cf_icon "btc", text: "Bitcoin"
# => <i class="cf-btc"></i> Bitcoin
cf_icon "btc-right", text: "Bitcoin", right: true
# => Bitcoin <i class="cf-btc-right"></i>
cf_icon "btc", data: { id: 123 }
# => <i class="cf-btc" data-id="123"></i>
content_tag(:li, cf_icon("ltc li", text: "Bulleted list item"))
# => <li><i class="cf-ltc fa-li"></i> Bulleted list item</li>
23 24 25 26 27 28 29 30 31 |
# File 'app/helpers/cryptofont/rails/icon_helper.rb', line 23 def cf_icon(names = 'flag', = {}) classes = [] classes.concat Private.icon_names(names) classes.concat Array(.delete(:class)) text = .delete(:text) right_icon = .delete(:right) icon = content_tag(:i, nil, .merge(class: classes)) Private.icon_join(icon, text, right_icon) end |