Module: Bootstrap3Helper

Defined in:
lib/bootstrap3_helper.rb,
lib/bootstrap3_helper/tabs.rb,
lib/bootstrap3_helper/alert.rb,
lib/bootstrap3_helper/panel.rb,
lib/bootstrap3_helper/callout.rb,
lib/bootstrap3_helper/railtie.rb,
lib/bootstrap3_helper/version.rb,
lib/bootstrap3_helper/accordion.rb,
lib/bootstrap3_helper/component.rb,
lib/bootstrap3_helper/tabs/menu.rb,
lib/bootstrap3_helper/tabs/content.rb,
lib/bootstrap3_helper/configuration.rb,
lib/bootstrap3_helper/tabs/dropdown.rb,
lib/bootstrap3_helper/accordion_group.rb

Overview

:nodoc:

Defined Under Namespace

Classes: Accordion, AccordionGroup, Alert, Callout, Component, Configuration, Panel, Railtie, Tabs

Constant Summary collapse

VERSION =
'2.0.0'.freeze

Instance Method Summary collapse

Instance Method Details

#accordion_group_helper(*args) {|group| ... } ⇒ String

Note:

All the element ids and data attributes needed to make the javascript function, are all synced up in the AccordionGroup and Accordion classes. You don’t need to worry about them.

Easily build a bootstrap accordion group component.

Examples:

Bootstrap Accordion Group Component:

<%= accordion_group_helper do |group| %>
  <% group.accordion class: 'primary' do |accordion| %>
      <%= accordion.header { "accordion 1" } %>
      <%= accordion.body do %>
          <p>This is accordion 1</p>
      <% end %>
  <% end %>
  <% group.accordion class: 'info' do |accordion| %>
      <%= accordion.header { "accordion 2" } %>
      <%= accordion.body do %>
          <p>This is accordion 2</p>
      <% end %>
  <% end %>
  <% group.accordion class: 'danger' do |accordion| %>
      <%= accordion.header { "accordion 3" } %>
      <%= accordion.body do %>
          <p>This is accordion 3</p>
      <% end %>
  <% end %>
<% end %>

Parameters:

  • args (Symbol|String|Hash|NilClass)

Yield Parameters:

Returns:

  • (String)


112
113
114
# File 'lib/bootstrap3_helper.rb', line 112

def accordion_group_helper(*args, &block)
  AccordionGroup.new(self, *args, &block)
end

#accordion_helper(*args) {|accordion| ... } ⇒ String

Easily build a bootstrap accordion component

Examples:

Bootstrap Panel Component:

<%= accordion_helper class: 'primary' do |accordion| %>
    <%= accordion.header do %>
        <span class="something">This is the heading....</span>
    <% end %>
    <%= accordion.body do %>
        <p>This is the body of the accordion....</p>
    <% end %>
<% end %>

Parameters:

  • args (Symbol|String|Hash|NilClass)

Yield Parameters:

Returns:

  • (String)


132
133
134
# File 'lib/bootstrap3_helper.rb', line 132

def accordion_helper(*args, &block)
  Accordion.new(self, *args, &block)
end

#alert_helper(*args, &block) ⇒ String

Creates an Alert component.

Examples:

Bootstrap Alert Component:

<%= alert_helper :danger, dismissble: true do %>
  Something went wrong with your model data...
<% end %>

Parameters:

  • args (Symbol|String|Hash|NilClass)

Yield Returns:

  • (String)

Returns:

  • (String)


52
53
54
# File 'lib/bootstrap3_helper.rb', line 52

def alert_helper(*args, &block)
  Alert.new(self, *args, &block)
end

#callout_helper(*args, &block) ⇒ String

Creates an Callout component.

Examples:

Bootstrap Callout Component:

<%= callout_helper :danger %>
  Some information that needs your attention...
<% end %>

Parameters:

  • args (Symbol|String|Hash|NilClass)

Yield Returns:

  • (String)

Returns:

  • (String)


67
68
69
# File 'lib/bootstrap3_helper.rb', line 67

def callout_helper(*args, &block)
  Callout.new(self, *args, &block)
end

#host_is_dev_pc?Boolean

Just a easy way of checking if the environment is a devbox or a server.

Returns:

  • (Boolean)


76
77
78
# File 'lib/bootstrap3_helper.rb', line 76

def host_is_dev_pc?
  Rails.root.to_s.include?('home')
end

#icon_helper(name) ⇒ Object

Note:

Only supply the last part of the glyph makrup.

Allows you to rapidly build bootstrap glyphs.

Examples:

Bootstrap Glyphicon Component:

<%= icon_helper('pencil') %>

Parameters:

  • name (String|Symbol)


145
146
147
# File 'lib/bootstrap3_helper.rb', line 145

def icon_helper(name)
   :span, '', class: "glyphicon glyphicon-#{name}"
end

#panel_helper(*args) {|panel| ... } ⇒ String

Allows you to rapidly build Panel components.

Examples:

Bootstrap Panel Component:

<%= panel_helper :primary do |p| %>
  <%= p.header { "Some Title" }
  <%= p.body class: 'custom-class', id: 'custom-id' do %>
    //HTML or Ruby code here...
  <% end %>
  <%= p.footer do %>
    //HTML or Ruby
  <% end %>
<% end %>

Parameters:

  • args (Symbol|String|Hash|NilClass)

Yield Parameters:

Returns:

  • (String)


37
38
39
# File 'lib/bootstrap3_helper.rb', line 37

def panel_helper(*args, &block)
  Panel.new(self, *args, &block)
end

#tabs_helper(args = {}) {|tabs| ... } ⇒ String

Note:

On menu items - you can pass in either symbol or string for the link. If you pass in a block, it will use the block for the title of the li. If no block is present, then it will titleize the symbol or string. Tabs::Menu will respond to item and dropdown Each method will yield the corresponding component, either a Tabs::Menu or a Tabs::Dropdown.

Used to rapidly build Tabs.

Examples:

Bootstrap Tabs Component:

<%= tabs_helper type: :pills do |menu, content| %>
  <%= menu.item(:testing1, class: 'active') { ' Testing 1' } %>
  <%= menu.item :testing2 %>
  <%= menu.item(:testing3) { ' Testing 3' } %>
  <%= menu.dropdown 'Testing Dropdown' do |dropdown| %>
      <%= dropdown.item(:testing5 ) { 'Testing 5' } %>
      <%= dropdown.item(:testing6 ) { 'Testing 6' } %>
      <%= dropdown.item(:testing7 ) { 'Testing 7' } %>
  <% end %>

  <%= content.item :testing1, class: 'active' do %>
      Testing 1 content
  <% end %>
  <%= content.item :testing2 do %>
      Testing 2 content
  <% end %>
  <%= content.item :testing3 do %>
      Testing 3 content
  <% end %>
  <%= content.item :testing5 do %>
      Testing 5 content
  <% end %>
  <%= content.item :testing6 do %>
      Testing 6 content
  <% end %>
  <%= content.item :testing7 do %>
      Testing 7 content
  <% end %>
<% end %>

Parameters:

  • args (Symbol|String|Hash|NilClass) (defaults to: {})

Yield Parameters:

Returns:

  • (String)


194
195
196
# File 'lib/bootstrap3_helper.rb', line 194

def tabs_helper(args = {}, &block)
  Tabs.new(self, args, &block)
end