Module: FontAwesomeSass::ViewHelper
- Defined in:
- lib/font_awesome-sass/view_helper.rb
Instance Method Summary collapse
- #awesome_btn(*args, &block) ⇒ Object
- #awesome_button(name, *args, &block) ⇒ Object
- #awesome_icon(name, *args, &block) ⇒ Object
Instance Method Details
#awesome_btn(*args, &block) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/font_awesome-sass/view_helper.rb', line 20 def awesome_btn *args, &block = args. size = [:size] if [:size] type = .delete(:type) if [:type] clazz = "btn" clazz << " btn-#{size}" if size clazz << " btn-#{type}" if type && %w{primary}.include?(type.to_s) href = .delete(:href) || '#' content_tag :a, {}.merge(class: clazz, href: href).merge([:btn] || {}) do capture(&block) end end |
#awesome_button(name, *args, &block) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/font_awesome-sass/view_helper.rb', line 36 def name, *args, &block = args. size = [:size] if [:size] type = .delete(:type) if [:type] clazz = "btn " clazz << " btn-#{size}" if size clazz << " btn-#{type}" if type && %w{primary}.include?(type.to_s) href = .delete(:href) || '#' content_tag :a, {}.merge(class: clazz, href: href).merge([:btn] || {}) do awesome_icon name, , &block end end |
#awesome_icon(name, *args, &block) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/font_awesome-sass/view_helper.rb', line 3 def awesome_icon name, *args, &block = args. size = .delete(:size) if content = args.first unless args.blank? content ||= capture(&block) if block_given? content ||= '' name = name.to_s.dasherize name.gsub! /^icon-/, '' clazz = "icon-#{name}" clazz << " icon-#{size}" if size.to_s == 'large' clazz << " " << .delete(:class) if [:class] content_tag(:i, nil, .merge(:class => clazz)) + content.html_safe end |