Module: Shoehorn::Helpers::LabelHelpers

Defined in:
lib/shoehorn/helpers/label_helpers.rb

Instance Method Summary collapse

Instance Method Details

#bootstrap_label(message, options = {}) ⇒ Object

Renders inline label

Examples

bootstrap_label("Hello!")
# => '<span class="label">Hello!</span>'

bootstrap_label("Hello!", type: 'warning')
# => '<span class="label label-warning">Hello!</span>'

bootstrap_label("Hello!", type: 'important', class: "my_awesome_class")
# => '<span class="my_awesome_class label label-important">Hello!</span>'

bootstrap_label("Hello!", type: 'info', bootstrap_class_prefix: "my_label")
# => '<span class="my_label my_label-info">Hello!</span>'

Returns HTML String for the label

Parameters:

  • message (String)

    message to be displayed

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

    hash containing options (default: {}): :type - The String type of alert to display: info, success, warning, important or inverse :class - The String additional CSS classes of the object :bootstrap_class_prefix - The String CSS class prefix from Twitter Bootstrap for the object :html_options - Any additional options you’d like to pass to the span tag that will be created

    for this label (for instance :"data-whatever" can be specified in :html_options).
    


29
30
31
32
33
34
# File 'lib/shoehorn/helpers/label_helpers.rb', line 29

def bootstrap_label(message, options = {})
  Shoehorn::Components::Label.new(
    message,
    options
  ).to_s
end