Class: Fuji::Link

Inherits:
Object
  • Object
show all
Defined in:
lib/fuji/link.rb

Instance Method Summary collapse

Constructor Details

#initialize(label, url, options = {}) ⇒ Link

Returns a new instance of Link.



4
5
6
7
8
# File 'lib/fuji/link.rb', line 4

def initialize label, url, options = {}
  @label = label
  @url = url
  @options = options
end

Instance Method Details

#html(current_page = nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/fuji/link.rb', line 10

def html current_page = nil
  url = mapping @url

  @options[:css] ||= Fuji::Helper.dehumanize(@label)
  css_class = [@options[:css]]
  css_class << "active" if current_page && current_page?(url, current_page)

  output = "<a href='#{url}' class='#{css_class.join(" ")}'>#{@label}</a>"
  output = "<li>#{output}</li>" unless @options[:skip_li]

  output
end