Sha256: f4e813e527321c0d39f0e1539350348774bfeaf29faa178027fdefb4cf4639ea

Contents?: true

Size: 719 Bytes

Versions: 7

Compression:

Stored size: 719 Bytes

Contents

module Railsstrap
  module IconHelper
    # ==== Examples
    # icon(:share_alt)
    # # => <span class="icon-share-alt"></span>
    # icon(:lock, :white)
    # # => <span class="icon-lock icon-white"></span>
    # icon(:thumbs_up, :pull_left)
    # # => <i class="icon-thumbs-up pull-left"></i>
    # icon(:lock, {tag: :span})
    # # => <span class="icon-lock"></span>
    def icon(*names)
      options = (names.last.kind_of?(Hash)) ? names.pop : {}
      names.map! { |name| name.to_s.gsub('_','-') }
      names.map! do |name|
        name =~ /pull-(?:left|right)/ ? name : "fa fa-#{name}"
      end
      options[:tag] = options[:tag] ||= :i
      content_tag options[:tag], nil, :class => names
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
railsstrap-3.3.4 app/helpers/railsstrap/icon_helper.rb
railsstrap-3.3.2 app/helpers/railsstrap/icon_helper.rb
railsstrap-3.3.1 app/helpers/railsstrap/icon_helper.rb
railsstrap-3.3.0 app/helpers/railsstrap/icon_helper.rb
railsstrap-3.2.0.3 app/helpers/railsstrap/icon_helper.rb
railsstrap-3.2.0.2 app/helpers/railsstrap/icon_helper.rb
railsstrap-3.2.0.1 app/helpers/railsstrap/icon_helper.rb