Sha256: c7d4661fbc2af3867d82428135ee49dcb2f619a3db47524f836ea2a96402a510

Contents?: true

Size: 934 Bytes

Versions: 1

Compression:

Stored size: 934 Bytes

Contents

module FontAwesome
  module Rails
    module IconHelper

      def fa_icon(icon, options = {})
        classes = ["fas"]
        classes << "fa-#{icon}"
        classes += options[:class].split(" ") unless options[:class].nil?
        classes += options[:size].split(" ").map{|s| "fa-#{s}"} unless options[:size].nil?
        classes += options[:animation].split(" ").map{|s| "fa-#{s}"} unless options[:animation].nil?
        classes = classes.uniq.join(" ")
        tags = []
        if options[:text].nil?
          content_tag(:i, nil, class: classes, style: options[:style], data: options[:data])
        else
          content_tag :span do
            tags << content_tag(:i, nil, class: classes, style: options[:style], data: options[:data])
            tags << content_tag(:span, options[:text], style: "padding-left: 5px;#{options[:style]}")
          end
          tags.join.html_safe
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
font_awesome5_rails-0.1.0 app/helpers/font_awesome/rails/icon_helper.rb