Method: Interview::NavigationItem#render

Defined in:
lib/interview/navigation_item.rb,
lib/interview/navigation_item_old.rb

#renderObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/interview/navigation_item.rb', line 9

def render
  css_class = "level#{ancestors.count-1}"
  css_class += " active" if @active
  show_siblings = @active || siblings.any? { |sib| sib.active }
  
  link = Link.new(parent: self, url: @url, controller: @controller, object: @object, 
    action: @action, http_method: @http_method, trail: @trail)
  badge = @badge_formula.call if @badge_formula
  unless badge.nil? or badge == 0 or badge == ''
    link.add_control(HtmlControl.new do |html| 
      html.span badge, class: 'badge pull-right'
    end)
  end
  link.add_control(HtmlControl.new do |html|
    html.span '', class: "glyphicon glyphicon-#{@image}" if @image
    html.text! ' ' if @image and @caption
    html << @caption if @caption
  end)
  
  html = Builder::XmlMarkup.new
  html.li class: css_class do  
    html << link.render
  end
  if show_siblings
    @controls.each do |c| 
      html << c.render 
    end
  end
  return html.target!
end