Module: Middleman::Features::Helpers::HelperMethods
- Defined in:
- lib/coolstrap-generator/middleman/helpers.rb
Instance Method Summary collapse
- #article(opts = {}, &block) ⇒ Object
- #dialog(opts, &block) ⇒ Object
- #divider(opts = {}, &block) ⇒ Object
-
#footer(opts = {}, &block) ⇒ Object
TODO separate elements in specific classes: views, asides, articles, header, tabbar, toolbar etc…
- #header(opts = {}, &block) ⇒ Object
- #hgroup(opts = {}, &block) ⇒ Object
- #icon(type, opts = {}, &block) ⇒ Object
- #list_item(opts = {}, &block) ⇒ Object
- #list_view(opts = {}, &block) ⇒ Object
- #nav(opts = {}, &block) ⇒ Object
- #render_dialog(dialog) ⇒ Object
- #render_tabbar(tabbar) ⇒ Object
- #render_toolbar(tabbar) ⇒ Object
- #section(opts = {}, &block) ⇒ Object
- #tabbar(opts = {}, &block) ⇒ Object
- #toolbar(opts = {}, &block) ⇒ Object
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) content_tag :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) = {:role => "dialog", :data=>{:type=>opts[:type] || "modal", :transition=>opts[:transition] || "slideup"}} opts = opts.merge() if block_given? content_tag(: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 |
#footer(opts = {}, &block) ⇒ Object
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 (opts={}, &block) content_tag :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) content_tag :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? content_tag :hgroup, do capture(&block) end else content_tag :hgroup do content_tag( :h1 , opts[:title]).concat( content_tag( :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) << content_tag( :i, "",{:class=>"icon-#{type}"}) else name = opts[:text].present? ? content_tag( :span, opts[:text]) : "" name << content_tag( :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) = {:class=>opts[:class]} = .merge({ :class=> "#{[:class]} list-divider"}) if opts[:divider] == true arrow = content_tag :div , :class=>"aside" do content_tag( :i, "",{:class=>"icon-chevron-#{opts[:arrow]}"}) end if opts[:arrow].present? if block_given? content_tag :li, do capture(&block) << (arrow || "") end else content_tag :li, do content_tag :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) = {:class=>opts[:class]}.merge({"data-type" => "listview"}) content_tag :ul, do capture(&block) end end |
#nav(opts = {}, &block) ⇒ Object
92 93 94 95 96 97 98 99 |
# File 'lib/coolstrap-generator/middleman/helpers.rb', line 92 def nav(opts={}, &block) if block_given? content_tag(: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/#{}") end |
#render_tabbar(tabbar) ⇒ Object
142 143 144 |
# File 'lib/coolstrap-generator/middleman/helpers.rb', line 142 def () partial("views/tabbars/#{}") end |
#render_toolbar(tabbar) ⇒ Object
150 151 152 |
# File 'lib/coolstrap-generator/middleman/helpers.rb', line 150 def () partial("views/toolbars/#{}") end |
#section(opts = {}, &block) ⇒ Object
29 30 31 32 33 |
# File 'lib/coolstrap-generator/middleman/helpers.rb', line 29 def section(opts={}, &block) content_tag :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 (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 (opts={}, &block) opts = opts.merge({"data-type" => "toolbar"}) if opts[:control] auto = opts[:auto] ? "autoWidth" : "" nav(opts.reject!{ |k| k == :control || k == :auto }) do content_tag(:div, :class=>"control-group #{auto}") do capture(&block) end end else nav(opts, &block) end end |