Module: Bootstrap::StampHelper

Defined in:
app/helpers/bootstrap/stamp_helper.rb

Overview

Rails helper for producing Twitter Bootstrap labels. We use #stamp() because #label() is a standard Rails helper method.

See: twitter.github.io/bootstrap/components.html#labels-badges

Examples:

stamp('Default')
stamp('Info', :info)  
stamp('Warning', :warning, id: 'warn-id', class: 'more-class', my_key: 'my_value')

Constant Summary collapse

InvalidStampTypeError =
Class.new(StandardError)
LABEL_TYPES =
%w(default success warning important info inverse)

Instance Method Summary collapse

Instance Method Details

#stamp(text, options = {}) ⇒ String #stamp(text, type, options = {}) ⇒ String

Returns a Bootstrap label

Overloads:

  • #stamp(text, options = {}) ⇒ String

    Returns a label of type :default

  • #stamp(text, type, options = {}) ⇒ String

    Returns a label of type type



30
31
32
33
34
# File 'app/helpers/bootstrap/stamp_helper.rb', line 30

def stamp(*args)
  text = args.shift
  options = add_label_classes(*args)
  (:span, text, options)
end