forked from pusewicz/twitter-bootstrap-markup-rails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
inline_label.rb
39 lines (32 loc) · 861 Bytes
/
inline_label.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
module Twitter::Bootstrap::Markup::Rails::Components
class InlineLabel < Base
attr_reader :message
def initialize(message, options = {})
super
@message = message
end
def to_s
output_buffer << content_tag(:span, message, build_tag_options).html_safe
super
end
private
def default_options
{
:class => nil,
:bootstrap_class_prefix => "label",
:type => nil,
:html_options => {}
}
end
def build_class
classes = [ options[:class] ]
classes << options[:bootstrap_class_prefix]
classes << "#{options[:bootstrap_class_prefix]}-#{options[:type]}" if options[:type]
classes.join(" ")
end
def build_tag_options
ops = {:class => build_class}
ops.reverse_merge(options[:html_options])
end
end
end