Module: FontAwesome5::Rails::IconHelper

Defined in:
app/helpers/font_awesome5/rails/icon_helper.rb

Instance Method Summary collapse

Instance Method Details

#fa_icon(icon, options = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'app/helpers/font_awesome5/rails/icon_helper.rb', line 9

def fa_icon(icon, options = {})
  parser = FaIconParser.new(icon, options)
  if parser.text.nil?
    (:i, nil, class: parser.classes, **parser.attrs)
  else
    (:i, nil, class: parser.classes, **parser.attrs) +
    (:span, parser.text, class: "fa5-text#{' ' unless parser.sizes.blank?}#{parser.sizes}", style: parser.style)
  end
end

#fa_layered_icon(options = {}, &block) ⇒ Object



31
32
33
34
35
36
37
38
39
40
# File 'app/helpers/font_awesome5/rails/icon_helper.rb', line 31

def fa_layered_icon(options = {}, &block)
  parser = FaLayeredIconParser.new(options)
  if parser.size.nil?
    (:span, class: parser.classes, title: parser.title, style: parser.style, &block)
  else
     :div, class: "fa-#{parser.size}" do
      (:span, class: parser.classes, title: parser.title, style: parser.style, &block)
    end
  end
end

#fa_stacked_icon(icon, options = {}) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'app/helpers/font_awesome5/rails/icon_helper.rb', line 20

def fa_stacked_icon(icon, options = {})
  parser = FaStackedIconParser.new(icon, options)

  tags =  :span, class: parser.span_classes, title: parser.title do
    (:i, nil, class: (parser.reverse ? parser.second_icon_classes : parser.first_icon_classes) ) +
    (:i, nil, class: (parser.reverse ? parser.first_icon_classes : parser.second_icon_classes) )
  end
  tags += parser.text unless parser.text.nil?
  tags
end