Module: Bh::PanelHelper

Includes:
BaseHelper
Included in:
Form::FieldsetHelper, PanelRowHelper
Defined in:
lib/bh/helpers/panel_helper.rb

Overview

Provides methods to include panels.

Instance Method Summary collapse

Instance Method Details

#panel(content_or_options_with_block = nil, options = nil, &block) ⇒ String

Returns an HTML block tag that follows the Bootstrap documentation on how to display panels.

The content of the panel can either be passed as the first parameter (in which case, the options are the second parameter), or as a block (in which case, the options are the first paramter).

Examples:

An panel with plain-text content passed as the first parameter.

panel 'Your profile was updated!', context: :info, title: 'Profile'

A panel with HTML content passed as a block.

panel context: :info, title: 'Profile'
  content_tag :strong, "Your profile was updated!"
end

Parameters:

  • content_or_options_with_block (String) (defaults to: nil)

    the content to display in the panel.

  • options (Hash) (defaults to: nil)

    the display options for the panel.

Options Hash (options):

  • :context (#to_s) — default: :default

    the contextual alternative to apply to the panel depending on its importance. Can be :default, :primary, :success, :info, :warning or :danger.

  • :body (#to_s)

    if present, the panel will include the provided text wrapped in a ‘panel-body’ block, for proper padding

  • :heading (#to_s)

    if present, the panel will include a heading with the provided text.

  • :title (#to_s)

    if present, the panel will include a heading with the provided text wrapped in a ‘panel-title’ block, for proper title styling and link coloring.

  • :tag (#to_s) — default: :div

    the HTML tag to wrap the panel in.

Returns:

  • (String)

    an HTML block tag for a panel.

See Also:



39
40
41
42
43
44
45
46
47
# File 'lib/bh/helpers/panel_helper.rb', line 39

def panel(content_or_options_with_block = nil, options = nil, &block)
  if block_given?
    panel_string capture(&block), content_or_options_with_block || {}
  elsif content_or_options_with_block.is_a?(Hash) && options.nil?
    panel_string nil, content_or_options_with_block
  else
    panel_string content_or_options_with_block, options || {}
  end
end