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/initialize.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 =
'3.0.1'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.config {|@_bs3h_config| ... } ⇒ Bootstrap5Helper::Configuration

Simple interface for exposing the configuration object.

Yields:

  • (@_bs3h_config)

Returns:

  • (Bootstrap5Helper::Configuration)


13
14
15
16
17
# File 'lib/bootstrap3_helper/initialize.rb', line 13

def config
  yield @_bs3h_config if block_given?

  @_bs3h_config
end

Instance Method Details

#accordion_group_helper(opts = {}) {|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:

```erb
<%= 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:

  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • :id (String)
  • :class (String)

Yield Parameters:

Returns:

  • (String)


58
59
60
# File 'lib/bootstrap3_helper.rb', line 58

def accordion_group_helper(opts = {}, &block)
  AccordionGroup.new(self, opts, &block)
end

#accordion_helper(context, opts) ⇒ String #accordion_helper(opts) ⇒ String

Easily build a bootstrap accordion component

Examples:

Bootstrap Panel Component:

```erb
<%= 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 %>
```

Overloads:

  • #accordion_helper(context, opts) ⇒ String

    Parameters:

    • context (Symbol|String)
      • :primary, :danger etc

    • opts (Hash)

    Options Hash (opts):

    • :id (String)
    • :class (String)
  • #accordion_helper(opts) ⇒ String

    Parameters:

    • opts (Hash)

    Options Hash (opts):

    • :id (String)
    • :class (String)

Yield Parameters:

Returns:

  • (String)


90
91
92
# File 'lib/bootstrap3_helper.rb', line 90

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

#alert_helper(context, opts) ⇒ String #alert_helper(opts) ⇒ String

Creates an Alert component.

Examples:

Bootstrap Alert Component:

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

Overloads:

  • #alert_helper(context, opts) ⇒ String

    Parameters:

    • context (Symbol|String)
      • :primary, :danger etc

    • opts (Hash)

    Options Hash (opts):

    • :id (String)
    • :class (String)
    • :dismissible (Boolean)
  • #alert_helper(opts) ⇒ String

    Parameters:

    • opts (Hash)

    Options Hash (opts):

    • :id (String)
    • :class (String)

Returns:

  • (String)


117
118
119
# File 'lib/bootstrap3_helper.rb', line 117

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

#callout_helper(context, opts) ⇒ String #callout_helper(opts) ⇒ String

Creates an Callout component.

Examples:

Bootstrap Callout Component:

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

Overloads:

  • #callout_helper(context, opts) ⇒ String

    Parameters:

    • context (Symbol|String)
      • :primary, :danger etc

    • opts (Hash)

    Options Hash (opts):

    • :id (String)
    • :class (String)
  • #callout_helper(opts) ⇒ String

    Parameters:

    • opts (Hash)

    Options Hash (opts):

    • :id (String)
    • :class (String)

Returns:

  • (String)


143
144
145
# File 'lib/bootstrap3_helper.rb', line 143

def callout_helper(*args, &block)
  Callout.new(self, *args, &block)
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)


156
157
158
# File 'lib/bootstrap3_helper.rb', line 156

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

#panel_helper(context, opts) ⇒ String #panel_helper(opts) ⇒ String

Allows you to rapidly build Panel components.

Examples:

Bootstrap Panel Component:

```erb
<%= panel_helper :default do |p| %>
  <%= p.header do %>
    <%= p.title { 'Some random text here' } %>
  <% end %>
  <%= p.body do %>
    //HTML & Ruby
  <% end %>
<% end %>
```

Overloads:

  • #panel_helper(context, opts) ⇒ String

    Parameters:

    • context (String|Symbol)
      • :primary, :danger etc

    • opts (Hash)

    Options Hash (opts):

    • :id (String)
    • :class (String)
    • :data (Hash)
    • :aria (Hash)
  • #panel_helper(opts) ⇒ String

    Parameters:

    • opts (Hash)

    Options Hash (opts):

    • :id (String)
    • :class (String)
    • :data (Hash)
    • :aria (Hash)

Yield Parameters:

Returns:

  • (String)


192
193
194
# File 'lib/bootstrap3_helper.rb', line 192

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

#tabs_helper(opts = {}) {|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 |tabs| %>
  <%= tabs.menu do |menu| %>
    <%= 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 %>
  <% end %>

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

Parameters:

  • opts (Hash) (defaults to: {})
  • args (Hash)

    a customizable set of options

Yield Parameters:

Returns:

  • (String)


247
248
249
# File 'lib/bootstrap3_helper.rb', line 247

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