Module: Ramaze::Helper::Link

Included in:
Pager
Defined in:
lib/ramaze/helper/link.rb

Overview

This is a modification of Innate::Helper::Link to respect the routing of Ramaze NOTE: The A/R/Rs methods have been deprecated.

Instance Method Summary collapse

Instance Method Details

#A(*args) ⇒ String

Returns:

See Also:

  • Innate::Helper#anchor


15
16
17
18
# File 'lib/ramaze/helper/link.rb', line 15

def A(*args)
  Ramaze.deprecated('Ramaze::Helper::Link#A', 'Ramaze::Helper::Link#a')
  a(*args)
end

Give it a path with character to split at and one to join the crumbs with. It will generate a list of links that act as pointers to previous pages on this path.

Example:

breadcrumbs('/path/to/somewhere')

# results in this, newlines added for readability:

<a href="/path">path</a>/
<a href="/path/to">to</a>/
<a href="/path/to/somewhere">somewhere</a>

Optionally a href prefix can be specified which generate link names a above, but with the prefix prepended to the href path.

Example:

breadcrumbs('/path/to/somewhere', '/', '/', '/mycontroller/action')

# results in this, newlines added for readability:

<a href="/mycontroller/action/path">path</a>/
<a href="/mycontroller/action/path/to">to</a>/
<a href="/mycontroller/action/path/to/somewhere">somewhere</a>

Returns:



64
65
66
67
68
69
70
71
72
# File 'lib/ramaze/helper/link.rb', line 64

def breadcrumbs(path, split = '/', join = '/', href_prefix = '')
  atoms = path.split(split).reject{|a| a.empty?}
  crumbs = atoms.inject([]){|s,v| s << [s.last,v]}
  bread = crumbs.map do |a|
    href_path = href_prefix + a*'/'
    a(a[-1], href_path)
  end
  bread.join(join)
end

#R(arg, *args) ⇒ String

Returns:

See Also:

  • Innate::Helper#route


22
23
24
25
# File 'lib/ramaze/helper/link.rb', line 22

def R(arg, *args)
  Ramaze.deprecated('Ramaze::Helper::Link#R', 'Ramaze::Helper::Link#r')
  (arg < Controller ? arg.r(*args) : r(arg, *args)).to_s
end

#route_location(klass) ⇒ Object



34
35
36
# File 'lib/ramaze/helper/link.rb', line 34

def route_location(klass)
  Ramaze.to(klass) || Ramaze.to(klass.class)
end

#Rs(*args) ⇒ String

Returns:

See Also:

  • Innate::Helper#route


29
30
31
32
# File 'lib/ramaze/helper/link.rb', line 29

def Rs(*args)
  Ramaze.deprecated('Ramaze::Helper::Link#Rs', 'Ramaze::Helper::Link#r')
  r(*args).to_s
end