Module: ActionView::Helpers::UrlHelper

Defined in:
lib/action_view/link_to_block/link_to_block.rb

Instance Method Summary collapse

Instance Method Details



24
25
26
# File 'lib/action_view/link_to_block/link_to_block.rb', line 24

def link_to_block_if(condition, name = nil, options = {}, html_options = {}, &block)
  link_to_block_unless !condition, name, options, html_options, &block
end


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/action_view/link_to_block/link_to_block.rb', line 7

def link_to_block_unless(condition, name = nil, options = {}, html_options = {}, &block)
  if condition
    if block_given?
      capture(&block)
    else
      ERB::Util.html_escape(name)
    end
  else
    if block_given?
      html_options, options = options, name
      link_to capture(&block), options, html_options
    else
      link_to name, options, html_options
    end
  end
end


28
29
30
31
32
33
34
35
# File 'lib/action_view/link_to_block/link_to_block.rb', line 28

def link_to_block_unless_current(name = nil, options = {}, html_options = {}, &block)
  if block_given?
    html_options, options = options, name
    link_to_block_unless current_page?(options), options, html_options, &block
  else
    link_to_block_unless current_page?(options), name, options, html_options
  end
end