Sha256: ea14cefb20aa2bcb515e4df59b5494460e1040b2efe3b678bd78042d4f07de96

Contents?: true

Size: 1.16 KB

Versions: 7

Compression:

Stored size: 1.16 KB

Contents

require 'bh/classes/icon'

module Bh
  module Helpers
    # Displays a Bootstrap-styled vector icon.
    # @see http://getbootstrap.com/components/#glyphicons
    # @see http://fortawesome.github.io/Font-Awesome/examples/#bootstrap
    # @return [String] the HTML to display a vector (font) icon.
    # @param [#to_s] name the name of the icon to display, with either dashes
    #   or underscores to separate multiple words.
    # @param [Hash] options the options for the icon tag. Any option not
    #   listed below is passed as an HTML attribute to the icon’s `<span>`.
    # @option options [#to_s] :library (:glyphicons) the vector icon library
    #   to use. Valid values are 'glyphicon', 'glyphicons' (for Glyphicons),
    #   'font-awesome', 'font_awesome' and 'fa' (for Font Awesome).
    # @example Display the "fire" font awesome icon with a title
    #   icon 'fire', library: :font_awesome, title: 'Hot'
    def icon(name = nil, options = {})
      icon = Bh::Icon.new self, nil, options.merge(name: name)
      icon.extract! :library, :name

      icon.append_class! icon.library_class
      icon.append_class! icon.name_class
      icon.render_tag :span
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
bh-1.3.6 lib/bh/helpers/icon_helper.rb
bh-1.3.5 lib/bh/helpers/icon_helper.rb
bh-1.3.4 lib/bh/helpers/icon_helper.rb
bh-1.3.3 lib/bh/helpers/icon_helper.rb
bh-1.3.1 lib/bh/helpers/icon_helper.rb
bh-1.3.0 lib/bh/helpers/icon_helper.rb
bh-1.2.0 lib/bh/helpers/icon_helper.rb