Class: RenderTreeHelper::Render

Inherits:
Object
  • Object
show all
Defined in:
app/helpers/render_tree_helper.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.hObject

Returns the value of attribute h.



12
13
14
# File 'app/helpers/render_tree_helper.rb', line 12

def h
  @h
end

.optionsObject

Returns the value of attribute options.



12
13
14
# File 'app/helpers/render_tree_helper.rb', line 12

def options
  @options
end

Class Method Details

.childrenObject



38
39
40
41
42
# File 'app/helpers/render_tree_helper.rb', line 38

def children
  unless options[:children].blank?
    "<ol class='tst_tree-list'>#{ options[:children] }</ol>"
  end
end

.render_node(h, options) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/helpers/render_tree_helper.rb', line 14

def render_node(h, options)
  @h, @options = h, options

  node = options[:node]
  "
    <li class='tst_tree-item'>
      <div class='tst_tree-item_content'>
        #{ show_link }
      </div>
      #{ children }
    </li>
  "
end


28
29
30
31
32
33
34
35
36
# File 'app/helpers/render_tree_helper.rb', line 28

def show_link
  node = options[:node]
  ns   = options[:namespace]
  url  = h.url_for(ns + [node])
  title_field = options[:title]
  klass = 'tst_tree-link'

  "<h4>#{ h.link_to(node.send(title_field), url, class: klass) }</h4>"
end