Class: Tungsten::SectionHelper::Section
- Defined in:
- app/helpers/tungsten/section_helper.rb
Instance Method Summary collapse
- #content(options = {}, &block) ⇒ Object
- #display(body) ⇒ Object
- #heading(text, options = {}) ⇒ Object
-
#initialize(title = nil, options = {}) ⇒ Section
constructor
A new instance of Section.
- #title(text = nil, options = {}, &block) ⇒ Object
Constructor Details
#initialize(title = nil, options = {}) ⇒ Section
Returns a new instance of Section.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'app/helpers/tungsten/section_helper.rb', line 5 def initialize( title = nil, = {} ) if title.is_a? Hash @options = title @title = nil else @options = @title = title end @id = @options[:id] end |
Instance Method Details
#content(options = {}, &block) ⇒ Object
45 46 47 |
# File 'app/helpers/tungsten/section_helper.rb', line 45 def content( ={}, &block ) content_tag( :div, class: 'app-section-content', &block ) end |
#display(body) ⇒ Object
17 18 19 20 21 22 23 |
# File 'app/helpers/tungsten/section_helper.rb', line 17 def display( body ) content_tag( :section, @options ) do @options[:class] = "app-section #{@options[:class]} #{"hidden" if @options.delete(:hidden)}".strip concat title( @title ) if @title concat body end end |
#heading(text, options = {}) ⇒ Object
39 40 41 42 43 |
# File 'app/helpers/tungsten/section_helper.rb', line 39 def heading( text, ={}) [:class] ||= '' [:class] << ' app-section-heading' content_tag( :h2, text, ) end |
#title(text = nil, options = {}, &block) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/helpers/tungsten/section_helper.rb', line 25 def title( text = nil, = {}, &block ) [:class] = "app-section-title #{[:class]}".strip if text text = content_tag( :a, text, href: "##{@id}", class: 'app-section-title-anchor' ) unless @id.nil? text = heading(text) end tag = content_tag( :div, ) { concat text concat content_tag( :div, class: 'app-section-description', &block) if block_given? } end |