TJBootstrapHelper

This is Tony Jian's Bootstrap helper gem.

Install

gme 'tj_bootstrap_helper'

or gem 'tj_bootstrap_helper', :git => "git://github.com/tonytonyjan/tj-bootstrap-helper.git"

Helpers Usage

<%= page_header @post.title %>
# => <div class="page-header"><h1><%= @post.content %></h1></div>

<%= page_header @post.title, 2 %>
# => <div class="page-header"><h2><%= @post.content %></h2></div>

spans

Render Array

<%= spans %w(asfd qwer zxcv), fluid: true do |word| %>
<h2><%= word %></h2>
<p>content</p>
<% end %>

# =>

asfd

content

qwer

content

zxcv

content

Render Resources

<%= spans @posts, :span => 3, :slice => 2 do |post| %>
<h2><%= post.title %></h2>
<p><%= post.content %></p>
<% end %>

# =>

<%= post.title %>

<%= post.content %>

<%= post.title %>

<%= post.content %>

...

<%= post.title %>

<%= post.content %>

<%= post.title %>

<%= post.content %>

thumbs

The usage of thumbs is nothing more than spans, but it requires a parameter of image method name correspondding to each resource.

Thumbnails Only

<%= thumbs @posts, "image_url", :span => 2, :slice => 2 %>

# =>
...

With Caption

<%= thumbs @posts, "image_url" do |post| %>
<h2><%= post.title %></h2>
<p><%= post.content %></p>
<% end %>

# =>
  • <%= image_tag post.image_url %>

    <%= post.title %>

    <%= post.content %>

  • ...