List can be used by two ways, one is passing a block, another is passing a collection as a parameter.

Unordered List

  1. = list do |li|
  2. - li << link_to('list 1', 'javascript:;')
  3. - li << link_to('list 2', 'javascript:;')
  4. - li << 'list 3'
  5. - li << link_to('list 4', 'javascript:;')
  6. - li << content_tag(:span, 'list 5', class: 'text-warning')

Ordered List

  1. list 1
  2. list 2
  3. list 3
  4. list 4
  5. list 5
  1. = list(type: 'ordered') do |li|
  2. - li << link_to('list 1', 'javascript:;')
  3. - li << link_to('list 2', 'javascript:;')
  4. - li << 'list 3'
  5. - li << link_to('list 4', 'javascript:;')
  6. - li << content_tag(:span, 'list 5', class: 'text-warning')

Unstyled List

  1. = list(type: 'unstyled') do |li|
  2. - li << link_to('list 1', 'javascript:;')
  3. - li << link_to('list 2', 'javascript:;')
  4. - li << 'list 3'
  5. - li << link_to('list 4', 'javascript:;')
  6. - li << content_tag(:span, 'list 5', class: 'text-warning')

Nested and with options

  1. list 1
  2. list 2
  3. list 3
    • list 3.1
    • list 3.2
    • list 3.3
  4. list 4
  5. list 5
  1. = list(type: 'ordered', style: 'background-color: #eeeeff', li_options: {style: 'color: #ff0000;'}) do |li|
  2. - li << link_to('list 1', 'javascript:;')
  3. - li << link_to('list 2', 'javascript:;')
  4. - li << link_to('list 3', 'javascript:;') + list(li_option: {style: 'color: #00ff00'}) do |nested_li|
  5. nested_li << 'list 3.1'
  6. nested_li << 'list 3.2'
  7. nested_li << 'list 3.3'
  8. end
  9. - li.add('list4', style: 'color: #00ff00')
  10. - li << content_tag(:span, 'list 5', class: 'text-warning')




Tab helper will generate a tabs or a pills component in bootstrap way.

Default Tab

I'm tab #1.
I'm tab #2.
I'm tab #3.
  1. = tabs do |t|
  2. - t.tab('tab1') do
  3. I'm tab #1.
  4. - t.tab('tab2') do
  5. I'm tab #2.
  6. - t.tab('tab3') do
  7. I'm tab #3.

Tab with options

I'm tab #1.
I'm tab #2.
I'm tab #3.
  1. = tabs(id: 'tabs_10', position: 'below') do |t|
  2. - t.tab('tab1', disabled: true, clickable: false) do
  3. I'm tab #1.
  4. - t.tab('tab2') do
  5. I'm tab #2.
  6. - t.tab('tab3') do
  7. I'm tab #3.

Stacked Tab

I'm tab #1.
I'm tab #2.
I'm tab #3.
  1. = tabs(id: 'tabs_20', stacked: true, class: 'span3', content_options: {class: 'span5'}) do |t|
  2. - t.tab('tab1', disabled: true, clickable: false) do
  3. I'm tab #1.
  4. - t.tab('tab2') do
  5. I'm tab #2.
  6. - t.tab('tab3') do
  7. I'm tab #3.

Default Pill

I'm tab #1.
I'm tab #2.
I'm tab #3.
  1. = tabs(style: 'pill', id: 'tab_30') do |t|
  2. - t.tab('tab1') do
  3. I'm tab #1.
  4. - t.tab('tab2') do
  5. I'm tab #2.
  6. - t.tab('tab3') do
  7. I'm tab #3.


Table helper wraps bootstrap table. It combines objects from the controller and table.

It has multiple options

Option Description
type It's a string splitted by space which represents bootstrap table type such as hover, bordered, stripped. For example: 'hover fluid', 'bordered condensed'
collection An object array or an ActiveRecord relation. Used to generate rows repeatly
caption Table's caption
caption_options Options can be accepted by caption tag
show_header True or false, whether to show the thead of the table
default_row_options Default row options that would be applied to all rows default
Other options can be accepted by table tag

Fluid table

Generate a table with fluid layout, pass a collection, you can specify the method should be called by the object in a column or use a code block.

Order NoOrder DateCustomer NameStatusActions
ON006-10-2013Customer Name 0Approved show | edit | destroy
ON106-10-2013Customer Name 1Approved show | edit | destroy
ON206-10-2013Customer Name 2Approved show | edit | destroy
ON306-10-2013Customer Name 3Approved show | edit | destroy
ON406-10-2013Customer Name 4Approved show | edit | destroy
  1. = table(collection: @orders, type: 'hover fluid') do |t|
  2. - t.column(width: 2, method: :order_number, align: 'center')
  3. - t.column(width: 2, method: :order_date) { |order| order.order_date.strftime("%d-%m-%Y") }
  4. - t.column(width: 2, method: :customer_name)
  5. - t.column(width: 2, method: :status)
  6. - t.column(width: 4, header_options: { text: 'Actions' }, align: 'center') do
  7. = link_to 'show', '#table'
  8. |
  9. = link_to 'edit', '#table'
  10. |
  11. = link_to 'destroy', '#table', confirm: 'sure?'

Fixed table

The default table is a non-fluid table.

Order NoOrder DateCustomer NameStatusActions
ON006-10-2013Customer Name 0Approved show | edit | destroy
ON106-10-2013Customer Name 1Approved show | edit | destroy
ON206-10-2013Customer Name 2Approved show | edit | destroy
ON306-10-2013Customer Name 3Approved show | edit | destroy
ON406-10-2013Customer Name 4Approved show | edit | destroy
  1. = table(collection: @orders) do |t|
  2. - t.column(width: 2, method: :order_number, align: 'center')
  3. - t.column(width: 2, method: :order_date) { |order| order.order_date.strftime("%d-%m-%Y") }
  4. - t.column(width: 2, method: :customer_name)
  5. - t.column(width: 2, method: :status)
  6. - t.column(width: 4, header_options: { text: 'Actions' }, align: 'center') do
  7. = link_to 'show', '#table'
  8. |
  9. = link_to 'edit', '#table'
  10. |
  11. = link_to 'destroy', '#table', confirm: 'sure?'

Table with options

Orders
Order NoDateCustomer NameStatusActions
ON006-10-2013Customer Name 0Approved show | edit | destroy
ON106-10-2013Customer Name 1Approved show | edit | destroy
ON206-10-2013Customer Name 2Approved show | edit | destroy
ON306-10-2013Customer Name 3Approved show | edit | destroy
ON406-10-2013Customer Name 4Approved show | edit | destroy
  1. = table(collection: @orders,
  2. type: 'fluid striped bordered condensed',
  3. caption: 'Orders',
  4. caption_options: { style: 'color: red; font-size: 16px;' },
  5. default_row_options: { style: 'background-color: #999;' }) do |t|
  6. - t.column(align: 'center', width: 2, method: :order_number)
  7. - t.column(header_options: { text: 'Date' }, width: 2, align: 'center') { |order| order.order_date.strftime('%d-%m-%Y') }
  8. - t.column(width: 2, method: :customer_name)
  9. - t.column(align: 'center', width: 2, method: :status)
  10. - t.column(align: 'center', width: 4, header_options: { text: 'Actions' }) do
  11. = link_to 'show', '#table'
  12. |
  13. = link_to 'edit', '#table'
  14. |
  15. = link_to 'destroy', '#table', confirm: 'sure?'
  16.  

Table with complex header

Order, as to 2014-06-08CustomerStatusActions
NumberDateshoweditdestroy
ON006-10-2013Customer Name 0Approvedshoweditdestroy
ON106-10-2013Customer Name 1Approvedshoweditdestroy
ON206-10-2013Customer Name 2Approvedshoweditdestroy
ON306-10-2013Customer Name 3Approvedshoweditdestroy
ON406-10-2013Customer Name 4Approvedshoweditdestroy
  1. = table(collection: @orders,
  2. type: "hover fluid bordered") do |t|
  3. - t.header_row do |r|
  4. - r.header(colspan: 2, align: 'center') { "Order, as to #{Date.today}" }
  5. - r.header(text: 'Customer', width: 3, rowspan: 2)
  6. - r.header(text: 'Status', width: 1, rowspan: 2, align: 'center')
  7. - r.header(text: 'Actions', width: 3, colspan: 3, align: 'center')
  8.  
  9. - t.header_row do |r|
  10. - r.header(text: 'Number', width: 2, align: 'center')
  11. - r.header(text: 'Date', width: 3, align: 'center')
  12. - r.header(text: 'show', width: 1, align: 'center')
  13. - r.header(text: 'edit', width: 1, align: 'center')
  14. - r.header(text: 'destroy', width: 1, align: 'center')
  15.  
  16. - t.column(align: 'center', method: :order_number)
  17. - t.column(align: 'center') { |order| order.order_date.strftime('%d-%m-%Y') }
  18. - t.column(method: :customer_name)
  19. - t.column(align: 'center', method: :status)
  20. - t.column(align: 'center') { link_to 'show', '#table' }
  21. - t.column(align: 'center') { link_to 'edit', '#table' }
  22. - t.column(align: 'center') { link_to 'destroy', '#table', confirm: 'sure?' }


Thumbnails helpers wraps bootstrap thumbnails component.

Thumbnails

  • 300x200

    Title

    Description

  • 300x200

    Title

    Description

  • 300x200

    Title

    Description

  • 600x200

    Title

    Description

  • 600x200

    Title

    Description

  1. = tns do
  2. = th(3) do
  3. = tn do
  4. = image_tag 'holder.js/300x200'
  5. %h3 Title
  6. %p Description
  7. = th(3) do
  8. = tn do
  9. = image_tag 'holder.js/300x200'
  10. %h3 Title
  11. %p Description
  12. = th(3) do
  13. = tn do
  14. = image_tag 'holder.js/300x200'
  15. %h3 Title
  16. %p Description
  17. = th(6) do
  18. = tn do
  19. = image_tag 'holder.js/600x200'
  20. %h3 Title
  21. %p Description
  22. = th(6) do
  23. = tn do
  24. = image_tag 'holder.js/600x200'
  25. %h3 Title
  26. %p Description


Flash helpers wraps bootstrap alerts component.

Default

×warning
  1. = f(message: 'warning')

With options

×error
×success
×info

This is an Info

The information here is a demo with block and without close button.

  1. = f(message: 'error', type: :error)
  2. = f(message: 'success', type: :success)
  3. = f(message: 'info', type: :info)
  4. = f(type: :info, block: true, closable: false) do
  5. %h4 This is an Info
  6. %p The information here is a demo with block and without close button.




Progress bar helpers wraps bootstrap progress bar component.

Non stacked bar

  1. = pg(percentage: 25, content: 'Done: 25%')
  2. = pg(striped: true, percentage: 25, content: 'Done: 25%')
  3. = pg(active: true, striped: true, percentage: 25, content: 'Done: 25%', type: :success)
  4. = pg(in_table: true, percentage: 25, content: 'Done: 25%', type: :warning)
  5. = pg(in_table: true, percentage: 25, content: 'Done: 25%', type: :danger)
  6. = pg(in_table: true, percentage: 25, content: 'Done: 25%', type: :info)

Stacked bar

Done: 25%
  1. = pg(striped: true, active: true) do
  2. = pb(percentage: 25, type: :success)
  3. = pb(percentage: 25, content: 'Done: 25%', type: :warning)


Typographic helpers includes bootstrap label, badge, hero unit, page header.

Label

this is a label text this is a label text this is a label text this is a label text this is a label text this is a label text
  1. = l('this is a label text')
  2. = l('this is a label text', type: :success)
  3. = l('this is a label text', type: :warning)
  4. = l('this is a label text', type: :important)
  5. = l('this is a label text', type: :info)
  6. = l('this is a label text', type: :inverse)

Badge

this is a badge text this is a badge text this is a badge text this is a badge text this is a badge text this is a badge text
  1. = b('this is a badge text')
  2. = b('this is a badge text', type: :success)
  3. = b('this is a badge text', type: :warning)
  4. = b('this is a badge text', type: :important)
  5. = b('this is a badge text', type: :info)
  6. = b('this is a badge text', type: :inverse)


Image helpers includes bootstrap glyph icon helper and image style helper.

Rounded border image

300x300
  1. = r_image_tag('holder.js/300x300')

Circle image

300x300
  1. = c_image_tag('holder.js/300x300')

Polaroid image

300x300
  1. = p_image_tag('holder.js/300x300')

Glyph icon

  1. = glyph_icon(:plus)
  1. = glyph_icon(:align_justify, :white)
  2. = glyph_icon(*%w(plus white))