Class: Interview::CollapseContainer
- Includes:
- HasControls
- Defined in:
- lib/interview/collapse_container.rb
Instance Attribute Summary collapse
-
#caption ⇒ Object
Returns the value of attribute caption.
Attributes included from HasControls
Attributes inherited from Control
Instance Method Summary collapse
Methods included from HasControls
#add_control, #add_controls, included, #initialize, #siblings
Methods inherited from Control
#ancestors, build, definition, #find_attribute, #find_attribute!, inherited, #initialize, #set_attributes, #set_defaults
Instance Attribute Details
#caption ⇒ Object
Returns the value of attribute caption.
5 6 7 |
# File 'lib/interview/collapse_container.rb', line 5 def caption @caption end |
Instance Method Details
#render ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/interview/collapse_container.rb', line 7 def render html = Builder::XmlMarkup.new if @caption link = Interview::Link.new(caption: @caption) controls = @controls else link = @controls.first controls = @controls[1..-1] end link.url = '#' link.html_class << 'collapse_link' link.html_data[:toggle] = 'collapse' new_id = Time.now.to_f.to_s.delete('.') link.html_data[:target] = "##{new_id}" html << link.render html.div id: new_id, class: 'panel-collapse collapse' do controls.each do |control| html << control.render end end return html.target! end |