You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
642 B

  1. # Font Awesome Helper
  2. module FaIconHelper
  3. # accept name without 'fa-' prefix, style: (solid by default), size:, class: and 'aria-hidden':
  4. def fa_icon(name, html_options = {})
  5. html_options[:style] ||= :solid
  6. html_options['aria-hidden'] ||= true
  7. content_class = "fa-#{to_dash(html_options[:style])} fa-#{to_dash(name)}"
  8. content_class << " fa-#{to_dash(html_options[:size])}" if html_options.key? :size
  9. content_class << " #{html_options[:class]}" if html_options.key? :class
  10. tag.i(class: content_class, 'aria-hidden': html_options['aria-hidden'])
  11. end
  12. private
  13. def to_dash(symbol) = symbol.to_s.dasherize
  14. end