Module: WeatherSeven::Rails::IconHelper

Defined in:
app/helpers/weather_seven/rails/icon_helper.rb

Defined Under Namespace

Modules: Private

Instance Method Summary collapse

Instance Method Details

#w7_icon(names = "wind", options = {}) ⇒ Object

Creates an icon tag given an icon name and possible icon modifiers.

Examples

w7_icon "wind"
# => <i class="pe-7w-wind"></i>

w7_icon "wind", class: "pull-left"
# => <i class="pe-7w-wind pull-left"></i>

w7_icon "wind", data: { id: 123 }
# => <i class="pe-7w-wind" data-id="123"></i>

(:li, w7_icon("wind", text: "Bulleted list item"))
# => <li><i class="pe-7w-wind"></i> Bulleted list item</li>


20
21
22
23
24
25
26
27
28
# File 'app/helpers/weather_seven/rails/icon_helper.rb', line 20

def w7_icon(names = "wind", options = {})
  classes = []
  classes.concat Private.icon_names(names)
  classes.concat Array(options.delete(:class))
  text = options.delete(:text)
  right_icon = options.delete(:right)
  icon = (:i, nil, options.merge(:class => classes))
  Private.icon_join(icon, text, right_icon)
end