Module: Bootstrap::BaseHelper
- Includes:
- ComponentHelper, ImageHelper, TabHelper, TableHelper, TypographyHelper
- Defined in:
- app/helpers/bootstrap/base_helper.rb
Instance Method Summary collapse
-
#div(options = {}, &block) ⇒ Object
Public: Simplify a div tag.
-
#merge_predef_class(new_class, options = {}) ⇒ Object
Public: Merge a new class into class option or ext_class option.
Methods included from TypographyHelper
Methods included from TableHelper
Methods included from TabHelper
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( = {}, &block) content_tag('div', nil, ) 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 - 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, = {}) existed_class = [:class] || [:ext_class] if existed_class.blank? [:class] = new_class else existed_class << " #{new_class}" end end |