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



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

def initialize
  self.panels = []
end

Instance Attribute Details

#panelsArray<Hash>



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

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.



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

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