Class: JqrHelpers::Helpers::PanelRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/jqr-helpers/helpers.rb

Overview

A renderer used for tabs, accordions, etc.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePanelRenderer



12
13
14
# File 'lib/jqr-helpers/helpers.rb', line 12

def initialize
  self.panels = []
end

Instance Attribute Details

#panelsArray<Hash>



10
11
12
# File 'lib/jqr-helpers/helpers.rb', line 10

def panels
  @panels
end

Instance Method Details

#panel(title, url_or_options = {}, options = {}, &block) ⇒ Object

Render a panel in the parent container. The panel must have either a URL or a block containing content.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/jqr-helpers/helpers.rb', line 24

def panel(title, url_or_options={}, options={}, &block)
  if url_or_options.is_a?(String)
    url = url_or_options
    content = ''
    id = nil
  else
    options = url_or_options
    content = yield
    id = Helpers._random_string
    url = '#' + id
  end
  options.merge!(:id => id)
  panels << {
    :title => title,
    :url => url,
    :options => options,
    :content => content
  }
  nil # suppress output
end