Sha256: 54f7dabb4f3ee6ad85a8318890f4c5281e77cacd05f460e76262ad84606e15c8

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

require 'railsstrap/classes/icon'

module Railsstrap
  module Helpers
    # Displays a Bootstrap-styled vector icon.
    # @see https://getbootstrap.com/docs/4.0/extend/icons/
    # @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),
    #   'far', 'fas' and 'fal' (for Font Awesome).
    # @example Display the "fire" font awesome standard icon with a title
    #   icon 'fire', library: :font_awesome, title: 'Hot'
    def icon(name = nil, options = {})
      icon = Railsstrap::Icon.new self, nil, options.merge(name: name)
      icon.extract! :library, :name, :tag

      icon.append_class! icon.library_class
      icon.append_class! icon.name_class
      icon.render_tag icon.tag
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
railsstrap-4.0.0.beta3 lib/railsstrap/helpers/icon_helper.rb
railsstrap-4.0.0.beta2 lib/railsstrap/helpers/icon_helper.rb