Twitter Bootstrap for Rails 3.1 Asset Pipeline using Haml/Sass/Coffeescript
Twitter Bootstrap is a design toolkit to kickstart the graphical part of webapps.
Usage in your Ruby on Rails app
Include Bootstrap in Gemfile:
Select your preferred Sass style
Select the your preferred sass-style in config/application.rb:
config.sass.preferred_syntax = :sass
config.sass.preferred_syntax = :scss
where the last one is the default.
Add an initializer “config/initializers/haml.rb”:
Haml::Template.options[:format] = :html5 Haml::Template.options[:attr_wrapper] = '"'
Install the assets
Remove the following files:
Install application.js.coffee and application.css.sass (or .scss):
rails g bootstrap:install
To create a new haml layout:
rails g bootstrap:layout [LAYOUT_NAME] [*ﬁxed or ﬂuid]
'LAYOUT_NAME' is the name of the layout. 'fixed' and 'fluid' is the style of the layout.
rails g bootstrap:layout application fixed
Make sure, that you do not have erb-versions of your layouts like 'app/views/layouts/application.html.erb' since they will be preferred by rails.
Themed generates Twitter Bootstrap compatible scaffold views:
rails g bootstrap:themed [RESOURCE_NAME]
rails g scaffold post title:string description:text rake db:migrate rails g bootstrap:themed posts
If you want to modify the themed templates, you can install them into you local app directory:
rails g bootstrap:templates
You will find them in 'lib/generators/bootstrap/themed/templates'.
The main part of bringing Twitter Bootstrap to Sass is done by Christopher Cocchi-Perrier: sass-twitter-bootstrap-rails
hsc-twitter-bootstrap-rails depends on the sass-twitter-bootstrap-rails gem.
Thomas Volkmar Worm <email@example.com>
Copyright © 2012 Thomas Volkmar Worm <firstname.lastname@example.org>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.