app/helpers/icon_helper.rb
# Generates a fontawesome icon
#
# === Expected parameters
#
# [icon]  the name of the icon to insert
# [html_options]  any options that should be passed to the tag() function
Generates a fontawesome icon
Expected parameters

[icon]  the name of the icon to insert
[html_options]  any options that should be passed to the tag() function
Generates a fontawesome icon Expected parameters [ icon ] the name of the icon to insert [ html_options ] any options that should be passed to the tag () function
def icon( icon, html_options = {} )
    html_options[:class] ||= ''
    html_options[:class] = "#{html_options[:class]} svg-icon svg-icon--#{icon}".strip
    html_options[:role] = 'img'
    if html_options.key?( :title ) && !html_options[:title].nil?
      id = "svg-icon__title--#{SecureRandom.hex(4)}"
      html_options[:'aria-labelledby'] = id
      title = content_tag("title", html_options[:title], id: id)
      html_options.delete :title
    else
      title = '';
      html_options[:'aria-hidden'] = 'true'
    end
    tag( 'svg', html_options, true ) + title + tag( 'use', 'xlink:href': "#icon-#{icon}" ) + '</svg>'.html_safe
  end
def icon ( icon , html_options = { } ) html_options [ :class ] ||= '' html_options [ :class ] = "#{html_options[:class]} svg-icon svg-icon--#{icon}" . strip html_options [ :role ] = 'img' if html_options . key? ( :title ) && ! html_options [ :title ] . nil? id = "svg-icon__title--#{SecureRandom.hex(4)}" html_options [ :' aria-labelledby ' ] = id title = content_tag ( "title" , html_options [ :title ] , id : id ) html_options . delete :title else title = '' ; html_options [ :' aria-hidden ' ] = 'true' end tag ( 'svg' , html_options , true ) + title + tag ( 'use' , 'xlink:href' : "#icon-#{icon}" ) + '</svg>' . html_safe end
Generates a fontawesome icon
 Expected parameters
Generates a fontawesome icon Expected parameters
# get a class # if we have a title # return
icon
html_options