Module: RenderSortableTreeHelper::Render

Defined in:
app/helpers/render_sortable_tree_helper.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.helperObject

Returns the value of attribute helper.



4
5
6
# File 'app/helpers/render_sortable_tree_helper.rb', line 4

def helper
  @helper
end

.optionsObject

Returns the value of attribute options.



4
5
6
# File 'app/helpers/render_sortable_tree_helper.rb', line 4

def options
  @options
end

Class Method Details

.childrenObject



28
29
30
31
32
# File 'app/helpers/render_sortable_tree_helper.rb', line 28

def children
  unless options[:children].blank?
    options[:children]
  end
end

.render_node(helper, options) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/helpers/render_sortable_tree_helper.rb', line 6

def render_node(helper, options)
  @helper, @options = helper, options
  node = options[:node]
  id_field = options[:id]
  li_attr_field = options[:li_attr]
  "
    <ul>
      <li id='#{ node.send(id_field) }' #{node.send(li_attr_field)} >
        #{ show_link }
        #{ children }
      </li>
    </ul>
  "
end


21
22
23
24
25
26
# File 'app/helpers/render_sortable_tree_helper.rb', line 21

def show_link
  node = options[:node]
  title_field = options[:title]
  a_attr_field = options[:a_attr]
  "<a #{node.send(a_attr_field)}>#{node.send(title_field)}</a>"
end