twitter_bootstrap_builder 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22,9 +22,9 @@ module TwitterBootstrapBuilder
22
22
  actions.to_s.html_safe
23
23
  end
24
24
 
25
- def display_field(method)
26
- ControlGroup.new(model.class.human_attribute_name(method)) do |cg|
27
- cg.append Tag.block(:span, model.send(method), class: 'display')
25
+ def display_field(method, options={})
26
+ ControlGroup.new(options[:label] || model.class.human_attribute_name(method)) do |cg|
27
+ cg.append Tag.block(:span, model.send(method).to_s.gsub("\n", '<br>'), class: 'display')
28
28
  end.to_s.html_safe
29
29
  end
30
30
 
@@ -70,6 +70,12 @@ module TwitterBootstrapBuilder
70
70
  end.to_s.html_safe
71
71
  end
72
72
 
73
+ def check_box(method, options={})
74
+ ControlGroup.new(model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
75
+ cg.append form_builder.check_box(method, options)
76
+ end.to_s.html_safe
77
+ end
78
+
73
79
  def hidden_field(method, options={})
74
80
  ControlGroup.new(model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
75
81
  cg.append form_builder.hidden_field(method, options)
@@ -30,6 +30,10 @@ module TwitterBootstrapBuilder
30
30
  Tag.block(:li, DropDownLinkBuilder.new(template, text: text, &block).html_safe).to_s.html_safe
31
31
  end
32
32
 
33
+ def custom(&block)
34
+ Tag.block(:li, Tag.block(:a, template.capture(self, &block))).to_s.html_safe
35
+ end
36
+
33
37
  end
34
38
  end
35
39
  end
@@ -26,7 +26,11 @@ module TwitterBootstrapBuilder
26
26
  end
27
27
 
28
28
  def divider
29
- Tag.block(:li, Divider.vertical).to_s.html_safe
29
+ Tag.block(:li, Divider.horizontal).to_s.html_safe
30
+ end
31
+
32
+ def custom(&block)
33
+ Tag.block(:li, template.capture(self, &block)).to_s.html_safe
30
34
  end
31
35
 
32
36
  end
@@ -0,0 +1,23 @@
1
+ module TwitterBootstrapBuilder
2
+ module Builders
3
+ class TabBuilder < Base
4
+
5
+ def initialize(*args, &block)
6
+ super
7
+ @tab = Tab.new
8
+ end
9
+
10
+ def to_s
11
+ template.capture(self, &block) if block
12
+ @tab.to_s
13
+ end
14
+
15
+ def content_for(text, id=nil, &block)
16
+ id = text.parameterize('_') unless id
17
+ @tab.nav.append NavTab.new(text, "##{id}")
18
+ @tab.content.append id, template.capture(self, &block) if block_given?
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -18,6 +18,16 @@ module TwitterBootstrapBuilder
18
18
  end
19
19
  end
20
20
 
21
+ def side_bar(partial=nil, &block)
22
+ if partial
23
+ content_for(:side_bar) { render "layouts/#{partial}" }
24
+ elsif block
25
+ content_for(:side_bar, &block)
26
+ else
27
+ content_for?(:side_bar) ? content_for(:side_bar) : nil
28
+ end
29
+ end
30
+
21
31
  def alert_message
22
32
  unless content_for?(:alert_message)
23
33
  if flash[:danger]
@@ -42,6 +52,10 @@ module TwitterBootstrapBuilder
42
52
  Builders::NavListBuilder.new(self, &block).html_safe
43
53
  end
44
54
 
55
+ def tab(&block)
56
+ Builders::TabBuilder.new(self, &block).html_safe
57
+ end
58
+
45
59
  def well(size=nil, &block)
46
60
  well = TwitterBootstrapMarkup::Well.new(capture(&block))
47
61
  well.send(size) if size
@@ -86,6 +100,16 @@ module TwitterBootstrapBuilder
86
100
  TwitterBootstrapMarkup::Icon.white(name).to_s.html_safe
87
101
  end
88
102
 
103
+ TwitterBootstrapMarkup::LabelBase::TYPES.each do |type|
104
+ define_method "label_#{type}" do |text|
105
+ TwitterBootstrapMarkup::Label.send(type, text).to_s.html_safe
106
+ end
107
+
108
+ define_method "badge_#{type}" do |text|
109
+ TwitterBootstrapMarkup::Badge.send(type, text).to_s.html_safe
110
+ end
111
+ end
112
+
89
113
  end
90
114
  end
91
115
  end
@@ -1,3 +1,3 @@
1
1
  module TwitterBootstrapBuilder
2
- VERSION = "0.0.2"
2
+ VERSION = '0.0.3'
3
3
  end
@@ -19,5 +19,6 @@ require 'twitter_bootstrap_builder/builders/nav_bar_builder'
19
19
  require 'twitter_bootstrap_builder/builders/nav_container_builder'
20
20
  require 'twitter_bootstrap_builder/builders/nav_list_builder'
21
21
  require 'twitter_bootstrap_builder/builders/submit_button_builder'
22
+ require 'twitter_bootstrap_builder/builders/tab_builder'
22
23
  require 'twitter_bootstrap_builder/builders/table_builder'
23
24