Module: TwitterBootstrapBuilder::Helpers::CommonsHelper

Defined in:
lib/twitter_bootstrap_builder/helpers/commons_helper.rb

Instance Method Summary collapse

Instance Method Details

#alert_messageObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/twitter_bootstrap_builder/helpers/commons_helper.rb', line 31

def alert_message
  unless content_for?(:alert_message)
    if flash[:danger]
      alert_danger(flash[:danger])
    elsif flash[:warning]
      alert_warning(flash[:warning])
    elsif flash[:success]
      alert_success(flash[:success])
    elsif flash[:info]
      alert_info(flash[:info])
    end
  end

  content_for?(:alert_message) ? content_for(:alert_message) : nil
end

#alert_validations(model) ⇒ Object



73
74
75
# File 'lib/twitter_bootstrap_builder/helpers/commons_helper.rb', line 73

def alert_validations(model)
  alert_danger(model.errors.full_messages.join('<br>')) if model.errors.any?
end

#badge(*args) ⇒ Object



107
108
109
# File 'lib/twitter_bootstrap_builder/helpers/commons_helper.rb', line 107

def badge(*args)
  TwitterBootstrapMarkup::Badge.new(*args).html_safe
end

#fieldset_horizontal(&block) ⇒ Object



91
92
93
# File 'lib/twitter_bootstrap_builder/helpers/commons_helper.rb', line 91

def fieldset_horizontal(&block)
  Builders::FieldsetBuilder.new(self, &block).html_safe
end

#fieldset_horizontal_for(model, &block) ⇒ Object



87
88
89
# File 'lib/twitter_bootstrap_builder/helpers/commons_helper.rb', line 87

def fieldset_horizontal_for(model, &block)
  Builders::FieldsetBuilder.new(self, model: model, &block).html_safe
end

#icon(*args) ⇒ Object



95
96
97
# File 'lib/twitter_bootstrap_builder/helpers/commons_helper.rb', line 95

def icon(*args)
  TwitterBootstrapMarkup::Icon.new(*args).html_safe
end

#icon_white(*args) ⇒ Object



99
100
101
# File 'lib/twitter_bootstrap_builder/helpers/commons_helper.rb', line 99

def icon_white(*args)
  TwitterBootstrapMarkup::Icon.white(*args).html_safe
end

#label(*args) ⇒ Object



103
104
105
# File 'lib/twitter_bootstrap_builder/helpers/commons_helper.rb', line 103

def label(*args)
  TwitterBootstrapMarkup::Label.new(*args).html_safe
end


47
48
49
# File 'lib/twitter_bootstrap_builder/helpers/commons_helper.rb', line 47

def nav_bar(&block)
  Builders::NavBarBuilder.new(self, &block).html_safe
end


51
52
53
# File 'lib/twitter_bootstrap_builder/helpers/commons_helper.rb', line 51

def nav_list(&block)
  Builders::NavListBuilder.new(self, &block).html_safe
end

#page_header(*args) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/twitter_bootstrap_builder/helpers/commons_helper.rb', line 13

def page_header(*args)
  if args.any?
    content_for(:page_header, TwitterBootstrapMarkup::PageHeader.new(args.shift, args.shift).html_safe)
  else
    content_for?(:page_header) ? content_for(:page_header) : nil
  end
end

#page_title(title = nil) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/twitter_bootstrap_builder/helpers/commons_helper.rb', line 5

def page_title(title=nil)
  if title
    content_for(:page_title, title)
  else
    content_for?(:page_title) ? content_for(:page_title) : nil
  end
end

#progress_bar(*args) ⇒ Object



121
122
123
# File 'lib/twitter_bootstrap_builder/helpers/commons_helper.rb', line 121

def progress_bar(*args)
  TwitterBootstrapMarkup::ProgressBar.new(*args).html_safe
end

#progress_bar_striped(*args) ⇒ Object



125
126
127
# File 'lib/twitter_bootstrap_builder/helpers/commons_helper.rb', line 125

def progress_bar_striped(*args)
  TwitterBootstrapMarkup::ProgressBar.new(*args).striped.html_safe
end

#progress_bar_striped_animated(*args) ⇒ Object



129
130
131
# File 'lib/twitter_bootstrap_builder/helpers/commons_helper.rb', line 129

def progress_bar_striped_animated(*args)
  TwitterBootstrapMarkup::ProgressBar.new(*args).striped_animated.html_safe
end


21
22
23
24
25
26
27
28
29
# File 'lib/twitter_bootstrap_builder/helpers/commons_helper.rb', line 21

def side_bar(partial=nil, &block)
  if partial
    content_for(:side_bar) { render "layouts/#{partial}" }
  elsif block
    content_for(:side_bar, &block)
  else
    content_for?(:side_bar) ? content_for(:side_bar) : nil
  end
end

#tab(&block) ⇒ Object



55
56
57
# File 'lib/twitter_bootstrap_builder/helpers/commons_helper.rb', line 55

def tab(&block)
  Builders::TabBuilder.new(self, &block).html_safe
end

#table_for(collection, model_class = nil, &block) ⇒ Object



83
84
85
# File 'lib/twitter_bootstrap_builder/helpers/commons_helper.rb', line 83

def table_for(collection, model_class=nil, &block)
  Builders::TableBuilder.new(self, collection: collection, model_class: model_class, &block).html_safe
end

#well(size = nil, &block) ⇒ Object



59
60
61
62
63
# File 'lib/twitter_bootstrap_builder/helpers/commons_helper.rb', line 59

def well(size=nil, &block)
  well = TwitterBootstrapMarkup::Well.new(capture(&block))
  well.send(size) if size
  well.html_safe
end

#well_large(&block) ⇒ Object



69
70
71
# File 'lib/twitter_bootstrap_builder/helpers/commons_helper.rb', line 69

def well_large(&block)
  well(:large, &block)
end

#well_small(&block) ⇒ Object



65
66
67
# File 'lib/twitter_bootstrap_builder/helpers/commons_helper.rb', line 65

def well_small(&block)
  well(:small, &block)
end