Module: Bootstrap::BaseHelper

Includes:
ComponentHelper, ImageHelper, TabHelper, TableHelper, TypographyHelper
Defined in:
app/helpers/bootstrap/base_helper.rb

Instance Method Summary collapse

Methods included from TypographyHelper

#list

Methods included from TableHelper

#table

Methods included from TabHelper

#tabs

Methods included from ImageHelper

#c_image_tag, #glyph_icon, #p_image_tag, #r_image_tag

Methods included from ComponentHelper

#badge, #btn_group, #btn_toolbar, #f, #l, #modal, #modal_trigger, #modal_with_trigger, #nav, #navbar, #progress, #progress_bar, #thumbnail, #thumbnail_holder, #thumbnails

Instance Method Details

#div(options = {}, &block) ⇒ Object

Public: Simplify a div tag.

options - Options can be accepted by div tag. block - The content of the div tag, can be other helpers or HTML tags

or just strings.

Examples

div(class: 'hero-unit')
# => <div class="hero-unit"></div>

= div(class: 'hero-unit') do
  h1 Hello World
# => <div class="hero-unit"><h1>Hello World</h1></div>

Returns the content wrapped by a div tag.



27
28
29
30
31
# File 'app/helpers/bootstrap/base_helper.rb', line 27

def div(options = {}, &block)
  ('div', nil, options) do
    capture(&block) if block_given?
  end
end

#merge_predef_class(new_class, options = {}) ⇒ Object

Public: Merge a new class into class option or ext_class option

new_class - the class string which needs to be merged to the existed

options.

options - the options ( default: {} )

Examples

merge_predef_class('nav nav-tabs', { id: 'tabs' })
# => { id: 'tabs', class: 'nav nav-tabs' }

merge_predef_class('nav nav-tabs', { id: 'tabs', class: 'foo' })
# => { id: 'tabs', class: 'foo nav nav-tabs' }

Returns the options argument itself.



48
49
50
51
52
53
54
55
56
57
58
# File 'app/helpers/bootstrap/base_helper.rb', line 48

def merge_predef_class(new_class, options = {})
  existed_class = options[:class] || options[:ext_class]

  if existed_class.blank?
    options[:class] = new_class
  else
    existed_class << " #{new_class}"
  end

  options
end