Module: Megatron::LayoutHelper

Defined in:
app/helpers/megatron/layout_helper.rb

Instance Method Summary collapse

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) {  :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(options={}, &block)
  @wide_layout = options[: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(options={}, &block)
  @custom_nav = options[:custom_nav]
  @primary_nav_here = options[:primary_nav]
  layout = options.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


33
34
35
# File 'app/helpers/megatron/layout_helper.rb', line 33

def sidebar(&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)
  options = options_from_args(args)
  tag = options[:tag] || :div
   tag, class: [width(*args), options[: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