Class: Leaf::ViewHelpers::ListRenderer

Inherits:
LinkRenderer show all
Defined in:
lib/leaf/view_helpers/list_renderer.rb

Instance Method Summary collapse

Methods inherited from LinkRenderer

#container_attributes, #prepare

Methods inherited from LinkRendererBase

#pagination, #prepare

Instance Method Details

#html_container(html) ⇒ Object



24
25
26
27
# File 'lib/leaf/view_helpers/list_renderer.rb', line 24

def html_container(html)
  tag(:div, "\n  " + 
    tag(:ul, html + "\n  ") + "\n", container_attributes) + "\n"
end

#previous_or_next_page(page, text, classname) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/leaf/view_helpers/list_renderer.rb', line 16

def previous_or_next_page(page, text, classname)
  if page
    link(tag(:span, text), page, :class => classname)
  else
    tag(:span, tag(:span, text), :class => classname + ' disabled')
  end
end

#to_htmlObject



6
7
8
9
10
11
12
13
14
# File 'lib/leaf/view_helpers/list_renderer.rb', line 6

def to_html
  html = pagination.map do |item|
    "\n    " + tag(:li, (item.is_a?(Fixnum) ?
      page_number(item) :
      send(item)))
  end.join(@options[:separator])
  
  @options[:container] ? html_container(html) : html
end