Coder Social home page Coder Social logo

bootstrap-helper's Introduction

Twitter Bootstrap Helper for Rails 3

Bootstrap is a toolkit from Twitter designed to kickstart development of webapps and sites. It includes base CSS and HTML for typography, forms, buttons, tables, grids, navigation, and more.

bootstrap_helper auto generates Bootstrap HTML codes.

Rails 3.1

include Bootstrap Helper in Gemfile;

gem 'bootstrap_helper'

or you can install from latest build;

gem 'bootstrap_helper', :git => "git://github.com/sapronlee/bootstrap-helper.git"

USAGE

render_page_title

SETUP

edit your config/application.rb

SITE_NAME = "YOUR SITE NAME"

in application.html.erb, replace <title> with

<%= render_page_title %>

define page title in your action

def index
  page_title("Posts Index")
end

will render

<title>Posts Index &raquo; YOUR SITE NAME</title>

render_list

render_list generates ul & li, auto append: "first", "last" class . If link matches current controller and acttion, it will auto add "active" class. Perfact for "menu"

<%= render_list :class => "nav" do |li|
     li << link_to(t("menu.topics"), topics_path)
     li << link_to(t("menu.wiki"), wikis_path )
     li << link_to(t("menu.sites"), sites_path )
     li << link_to(t("menu.users"), users_path)
end %>

render_body_tag

in application.html.erb, replace <body> with

<%= render_body_tag %> 

render_body_tag auto inserts "controller name" & "action name" in to body class, and generates �IE conditional comment.

<!--[if lt IE 7 ]>
<body class="topics-controller index-action ie6"><![endif]-->
<!--[if gte IE 7 ]>
<body class="topics-controller index-action ie"><![endif]-->
<!--[if !IE]>-->
<body class="topics-controller index-action">
<!--<![endif]-->

breadcrumb

in application.html.erb, place this helper

<%= render_breadcrumb %>

drop breadcrumb in your action

def show
  @post = Posts.find(params[:id])
  drop_breadcrumb("Posts", posts_path)
  drop_breadcrumb(@post.title)
end

it will generate breadcrumb with link for you

Home / Post / YourPostTitle

notice_message

in application.html.erb, place this helper

<%= notice_message %>

write notice message in your action, will generate bootstrap style notice message

def create
  # ….
  redirect_to posts_path, :notice => "Create Success!"
end

def update
  redirect_to root_path, :flash => { :warning => "Update Success!" }
end
def no_permission
  redirect_to root_path, :flash => { :error => "no permission" }
end

Pagination

Support will_paginate, ~> 3.0.3

Markup Example

see example

Other

Form

Support simple_form, ~> 2.0.2

You can use simple_form 2.0 with bootstrap form template

<%= simple_form_for @article do |f| %>
   <%= f.input :title, :input_html => {:class => "xxlarge"} , :hint => "this is post title" %>
<% end >

Thanks

Thanks Twitter for Bootstrap http://twitter.github.com/bootstrap

Thanks Handlino for HandicraftHelper https://github.com/handlino/handicraft_helper

License

Copyright (C) 2011 by xdite

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.

bootstrap-helper's People

Contributors

kristianmandrup avatar linyiru avatar matiss avatar sapronlee avatar sebjacobs avatar xdite avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.