Module: UiHelpers::LinkHelpers

Included in:
ActionViewExtension
Defined in:
lib/ui_helpers/helpers/link.rb

Instance Method Summary collapse

Instance Method Details



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/ui_helpers/helpers/link.rb', line 3

def link_with_icon_to(name = nil, options = nil, html_options = nil, &block)
  if block_given?
    content, path, options = capture(&block), name, options
  else
    content, path, options = name, options, html_options
  end
  options ||= {}
  options = options.stringify_keys

  options["style"] = [options["style"], "white-space: nowrap;"].compact.join(" ")

  icon = options.delete("icon")
  content = UiHelpers::LinkIcon.new(self, icon).tag(:span) + content

  link_to(content, path, options)
end


20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ui_helpers/helpers/link.rb', line 20

def link_with_icon_to_function(name, function, html_options={})
  content = name
  options = html_options
  options = options.stringify_keys

  options["style"] = [options["style"], "white-space: nowrap;"].compact.join(" ")

  icon = options.delete("icon")
  content = UiHelpers::LinkIcon.new(self, icon).tag(:span) + content

  link_to_function(content, function, options)    
end