Module: Megatron::LayoutHelper
- Defined in:
- app/helpers/megatron/layout_helper.rb
Instance Method Summary collapse
- #header(type, title = nil, &block) ⇒ Object
- #main(options = {}, &block) ⇒ Object
- #main_header(title = nil, &block) ⇒ Object
- #megatron_layout(options = {}, &block) ⇒ Object
- #page_header(title = nil, &block) ⇒ Object
- #sidebar(&block) ⇒ Object
- #size(*args, &block) ⇒ Object
- #width(*sizes) ⇒ Object
Instance Method Details
#header(type, title = nil, &block) ⇒ Object
20 21 22 23 24 25 26 |
# File 'app/helpers/megatron/layout_helper.rb', line 20 def header(type, title = nil, &block) if title content_for(type) { content_tag :h2, title } elsif !title && block_given? content_for type, &block end end |
#main(options = {}, &block) ⇒ Object
28 29 30 31 |
# File 'app/helpers/megatron/layout_helper.rb', line 28 def main(={}, &block) @wide_layout = [:wide] content_for :main, &block end |
#main_header(title = nil, &block) ⇒ Object
16 17 18 |
# File 'app/helpers/megatron/layout_helper.rb', line 16 def main_header(title = nil, &block) header :main_header, title, &block end |
#megatron_layout(options = {}, &block) ⇒ Object
4 5 6 7 8 9 10 |
# File 'app/helpers/megatron/layout_helper.rb', line 4 def megatron_layout(={}, &block) @custom_nav = [:custom_nav] @primary_nav_here = [:primary_nav] layout = .delete(:layout) || 'default' yield render_layout "megatron/#{layout}" end |
#page_header(title = nil, &block) ⇒ Object
12 13 14 |
# File 'app/helpers/megatron/layout_helper.rb', line 12 def page_header(title = nil, &block) header :page_header, title, &block end |
#sidebar(&block) ⇒ Object
33 34 35 |
# File 'app/helpers/megatron/layout_helper.rb', line 33 def (&block) content_for :sidebar, &block end |
#size(*args, &block) ⇒ Object
37 38 39 40 41 |
# File 'app/helpers/megatron/layout_helper.rb', line 37 def size(*args, &block) = (args) tag = [:tag] || :div content_tag tag, class: [width(*args), [:class]], &block end |
#width(*sizes) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/helpers/megatron/layout_helper.rb', line 43 def width(*sizes) media = '' sizes.flatten! if sizes.first.is_a?(Symbol) || sizes.first.is_a?(String) media = "#{sizes.shift.to_s.sub(/^x/, 'x-')}-" end classes = "#{media}#{sizes[0].to_words}-of-#{sizes[1].to_words}" if sizes.last.is_a? Hash classes << " #{sizes.last[:class]}" end classes end |