Module: Middleman::Features::Helpers::HelperMethods

Defined in:
lib/coolstrap-generator/middleman/helpers.rb

Instance Method Summary collapse

Instance Method Details

#article(opts = {}, &block) ⇒ Object


23
24
25
26
27
# File 'lib/coolstrap-generator/middleman/helpers.rb', line 23

def article(opts={}, &block)
    :article , opts do 
      capture(&block)
   end 
end

#dialog(opts, &block) ⇒ Object


131
132
133
134
135
136
137
138
139
140
# File 'lib/coolstrap-generator/middleman/helpers.rb', line 131

def dialog(opts, &block)
  options = {:role => "dialog", :data=>{:type=>opts[:type] || "modal", :transition=>opts[:transition] || "slideup"}}
  opts = opts.merge(options)
  if block_given?
    (:div, opts) do
      capture(&block)
    end
  else
  end
end

#divider(opts = {}, &block) ⇒ Object


82
83
84
85
86
87
88
89
90
# File 'lib/coolstrap-generator/middleman/helpers.rb', line 82

def divider(opts={}, &block)
  if block_given?
    list_item({:divider=>true}.merge(opts)) do
      capture(&block)
    end
  else
    list_item({:divider=>true}.merge(opts))
  end
end

TODO separate elements in specific classes: views, asides, articles, header, tabbar, toolbar etc…


17
18
19
20
21
# File 'lib/coolstrap-generator/middleman/helpers.rb', line 17

def footer(opts={}, &block)
    :footer , opts do 
      capture(&block)
   end 
end

#header(opts = {}, &block) ⇒ Object


35
36
37
38
39
# File 'lib/coolstrap-generator/middleman/helpers.rb', line 35

def header(opts={}, &block)
    :header , opts do 
      capture(&block)
   end 
end

#hgroup(opts = {}, &block) ⇒ Object


41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/coolstrap-generator/middleman/helpers.rb', line 41

def hgroup(opts={}, &block)
  if block_given?
     :hgroup, options do 
       capture(&block)
    end
  else
     :hgroup do
      ( :h1 , opts[:title]).concat(
      ( :h2 , opts[:subtitle])
      )
    end
  end
end

#icon(type, opts = {}, &block) ⇒ Object


120
121
122
123
124
125
126
127
128
129
# File 'lib/coolstrap-generator/middleman/helpers.rb', line 120

def icon(type, opts={}, &block)
  if block_given?
    capture(&block) <<
    ( :i, "",{:class=>"icon-#{type}"})
  else
    name = opts[:text].present? ? ( :span, opts[:text]) : ""
    name <<
    ( :i, "",{:class=>"icon-#{type}"})
  end
end

#list_item(opts = {}, &block) ⇒ Object


62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/coolstrap-generator/middleman/helpers.rb', line 62

def list_item(opts={}, &block)
  options = {:class=>opts[:class]}
  options = options.merge({ :class=>  "#{options[:class]} list-divider"}) if opts[:divider] == true
  arrow =  :div , :class=>"aside" do
            ( :i, "",{:class=>"icon-chevron-#{opts[:arrow]}"})
          end if opts[:arrow].present? 
  
  if block_given?
     :li, options do
      capture(&block) << (arrow || "")
    end
  else
     :li, options do 
       :h1 do
        opts[:content]
      end
    end
  end
end

#list_view(opts = {}, &block) ⇒ Object


55
56
57
58
59
60
# File 'lib/coolstrap-generator/middleman/helpers.rb', line 55

def list_view(opts={}, &block)
  options = {:class=>opts[:class]}.merge({"data-type" => "listview"})
   :ul, options do 
     capture(&block)
  end
end

92
93
94
95
96
97
98
99
# File 'lib/coolstrap-generator/middleman/helpers.rb', line 92

def nav(opts={}, &block)
  if block_given?
    (:nav, opts) do
      capture(&block)
    end
  else
  end
end

#render_dialog(dialog) ⇒ Object


146
147
148
# File 'lib/coolstrap-generator/middleman/helpers.rb', line 146

def render_dialog(dialog)
  partial("views/dialogs/#{tabbar}")
end

#render_tabbar(tabbar) ⇒ Object


142
143
144
# File 'lib/coolstrap-generator/middleman/helpers.rb', line 142

def render_tabbar(tabbar)
  partial("views/tabbars/#{tabbar}")
end

#render_toolbar(tabbar) ⇒ Object


150
151
152
# File 'lib/coolstrap-generator/middleman/helpers.rb', line 150

def render_toolbar(tabbar)
  partial("views/toolbars/#{tabbar}")
end

#section(opts = {}, &block) ⇒ Object


29
30
31
32
33
# File 'lib/coolstrap-generator/middleman/helpers.rb', line 29

def section(opts={}, &block)
    :section , opts do 
      capture(&block)
   end 
end

#tabbar(opts = {}, &block) ⇒ Object


101
102
103
104
# File 'lib/coolstrap-generator/middleman/helpers.rb', line 101

def tabbar(opts={}, &block)
  opts = opts.merge({"data-type" => "tabbar"})
  nav(opts, &block)
end

#toolbar(opts = {}, &block) ⇒ Object


106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/coolstrap-generator/middleman/helpers.rb', line 106

def toolbar(opts={}, &block)
  opts = opts.merge({"data-type" => "toolbar"})
  if opts[:control]
    auto = opts[:auto] ? "autoWidth" : ""
    nav(opts.reject!{ |k| k == :control || k == :auto }) do
      (:div, :class=>"control-group #{auto}") do
        capture(&block)
      end
    end
  else
    nav(opts, &block)
  end
end