Accordion Rails helper for Twitter Bootstrap

Like many, I’m living the Twitter Bootstrap craze in full these days. It’s applied to several applications I’m currently working on and two of them needed an accordion.

The Twitter Bootstrap accordion is great but requires quite a bit of infrastructure (divs, classes, hrefs and data attributes) so I set on writing a helper to clean up my views. I ended up with a 40 line helper module that I wanted to use in two different projects.

Following the micro gems trend, I bundled this in a gist. It can be used as follows :

In your Gemfile :

gem 'bootstrap-components-helpers',
        :git => 'git://gist.github.com/2117187.git'

In your views :

= accordion do |accordion|
  = accordion.pane 'My first pane' do
    = render partial: 'my_first_pane'
  = accordion.pane 'My second pane' do
    = render partial: 'my_second_pane'

Update: it now does tabs as well.

  1. dbinsights posted this
Short URL for this post: http://tmblr.co/Z7WmhvIEswZC
blog comments powered by Disqus