Module: RailsBootstrapHelpers::Helpers::BaseHelper

Includes:
OptionsHelper
Included in:
Renderers::ButtonRenderer
Defined in:
lib/rails-bootstrap-helpers/helpers/base_helper.rb

Instance Method Summary collapse

Methods included from OptionsHelper

#append_class!, #bs_options

Instance Method Details

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

Renders the given icon

Renders an i tag with the class “icon-##icon

Parameters:

  • icon (String, Symbol)

    the kind of icon to render

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :invert (Boolean) — default: false

    if the color of the icon should be inverted



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rails-bootstrap-helpers/helpers/base_helper.rb', line 11

def icon (icon, options = {})
  options = options.dup

  icon = ERB::Util.html_escape(icon.to_s)
  append_class!(options, "icon-" + icon)

  if options.delete(:invert)
    append_class!(options, "icon-white")
  end

  cls = options[:class]

  "<i class=\"#{cls}\"></i>".html_safe
end

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

Renders the given Iconic icon.

This is the Iconic icons from Jasny Bootstrap. Renders an i tag with the class “iconic-##icon

Parameters:

  • icon (String, Symbol)

    the kind of icon to render

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :color (String, Symbol)

    the CSS color of the icon

  • :size (String, Symbol, Number)

    the CSS font size of the icon

  • :bs_style (:warning, :error, :info, :success, :muted)

    the Bootstrap style to render the icon in

  • :action_style (:primary, :info, :success, :warning, :danger)

    renders the icon with this action link style



41
42
43
# File 'lib/rails-bootstrap-helpers/helpers/base_helper.rb', line 41

def iconic_icon (icon, options = {})
  RailsBootstrapHelpers::Renderers::IconicIconRenderer.new(self, icon, options).render
end