Module: FontAwesomeSass::ViewHelper

Defined in:
lib/font_awesome-sass/view_helper.rb

Instance Method Summary collapse

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
  options = args.extract_options!
  size = options[:size] if options[:size]
  type = options.delete(:type) if options[:type]

  clazz = "btn"
  clazz << " btn-#{size}" if size
  clazz << " btn-#{type}" if type && %w{primary}.include?(type.to_s)

  href = options.delete(:href) || '#'

   :a, {}.merge(class: clazz, href: href).merge(options[: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 awesome_button name, *args, &block
  options = args.extract_options!
  size = options[:size] if options[:size]
  type = options.delete(:type) if options[:type]

  clazz = "btn "
  clazz << " btn-#{size}" if size
  clazz << " btn-#{type}" if type && %w{primary}.include?(type.to_s)

  href = options.delete(:href) || '#'

   :a, {}.merge(class: clazz, href: href).merge(options[:btn] || {}) do
    awesome_icon name, options, &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
  options = args.extract_options!
  size = options.delete(:size) if options
  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 << " " << options.delete(:class) if options[:class]

  (:i, nil, options.merge(:class => clazz)) + content.html_safe
end