twitter-bootstrap-rails 4.0.0 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of twitter-bootstrap-rails might be problematic. Click here for more details.

data/README.md CHANGED
@@ -1,638 +1,638 @@
1
- # Twitter Bootstrap for Rails 5 and Rails 4 Asset Pipeline
2
-
3
- Bootstrap is a toolkit from Twitter designed to kickstart development of web apps and sites. It includes base CSS and HTML for typography, forms, buttons, tables, grids, navigation, and more.
4
-
5
- twitter-bootstrap-rails project integrates Bootstrap CSS toolkit for Rails Asset Pipeline (Rails 4, 3.x versions are supported)
6
-
7
- [![Gem Version](https://badge.fury.io/rb/twitter-bootstrap-rails.svg)](http://badge.fury.io/rb/twitter-bootstrap-rails)
8
- [![Dependency Status](https://gemnasium.com/seyhunak/twitter-bootstrap-rails.svg?travis)](https://gemnasium.com/seyhunak/twitter-bootstrap-rails?travis)
9
- [![Code Climate](https://codeclimate.com/github/seyhunak/twitter-bootstrap-rails/badges/gpa.svg)](https://codeclimate.com/github/seyhunak/twitter-bootstrap-rails?branch=master)
10
- [![Coverage Status](https://coveralls.io/repos/seyhunak/twitter-bootstrap-rails/badge.png?branch=master)](https://coveralls.io/repos/seyhunak/twitter-bootstrap-rails/badge.png?branch=master)
11
- [![GitHub stars](https://img.shields.io/github/stars/seyhunak/twitter-bootstrap-rails.svg)](https://github.com/seyhunak/twitter-bootstrap-rails/stargazers)
12
- [![GitHub forks](https://img.shields.io/github/forks/seyhunak/twitter-bootstrap-rails.svg)](https://github.com/seyhunak/twitter-bootstrap-rails/network)
13
- [![GitHub issues](https://img.shields.io/github/issues/seyhunak/twitter-bootstrap-rails.svg)](https://github.com/seyhunak/twitter-bootstrap-rails/issues)
14
-
15
- ## Screencasts
16
- #### Installing twitter-bootstrap-rails, generators, usage and more
17
- <img width="180" height="35" src="http://oi49.tinypic.com/s5wn05.jpg"></img>
18
-
19
- Screencasts provided by <a href="http://railscasts.com">RailsCasts</a> (Ryan Bates)
20
-
21
- [Twitter Bootstrap Basics](http://railscasts.com/episodes/328-twitter-bootstrap-basics "Twitter Bootstrap Basics")
22
- in this episode you will learn how to include Bootstrap into Rails application with the twitter-bootstrap-rails gem.
23
-
24
- [More on Twitter Bootstrap](http://railscasts.com/episodes/329-more-on-twitter-bootstrap "More on Twitter Bootstrap")
25
- in this episode continues on the Bootstrap project showing how to display flash messages, add form validations with SimpleForm, customise layout with variables, and switch to using Sass.
26
- (Note: This episode is pro episode)
27
-
28
- ## Installing the Gem
29
-
30
- The [Twitter Bootstrap Rails gem](http://rubygems.org/gems/twitter-bootstrap-rails) can provide the Bootstrap stylesheets in two ways.
31
-
32
- The plain CSS way is how Bootstrap is provided on [the official website](http://twbs.github.io/bootstrap/).
33
-
34
- The [Less](http://lesscss.org/) way provides more customisation options, like changing theme colors and provides useful Less mixins for your code, but requires the
35
- Less gem and the Ruby Racer Javascript runtime (not available on Microsoft Windows).
36
-
37
- ### Installing the Less stylesheets
38
-
39
- To use Less stylesheets, you'll need the [less-rails gem](http://rubygems.org/gems/less-rails), and one of [JavaScript runtimes supported by CommonJS](https://github.com/cowboyd/commonjs.rb#supported-runtimes).
40
-
41
- Include these lines in the Gemfile to install the gems from [RubyGems.org](http://rubygems.org):
42
-
43
- ```ruby
44
- gem "therubyracer"
45
- gem "less-rails" #Sprockets (what Rails 3.1 uses for its asset pipeline) supports LESS
46
- gem "twitter-bootstrap-rails"
47
- ```
48
-
49
- or you can install from latest build;
50
-
51
- ```ruby
52
- gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git'
53
- ```
54
-
55
- Then run `bundle install` from the command line:
56
-
57
- bundle install
58
-
59
- Then run the bootstrap generator to add Bootstrap includes into your assets:
60
-
61
- rails generate bootstrap:install less
62
-
63
- If you need to skip coffeescript replacement into app generators, use:
64
-
65
- rails generate bootstrap:install --no-coffeescript
66
-
67
- ### Installing the CSS stylesheets
68
-
69
- If you don't need to customize the stylesheets using Less, the only gem you need is the `twitter-bootstrap-rails` gem:
70
-
71
- ```ruby
72
- gem "twitter-bootstrap-rails"
73
- ```
74
-
75
- After running `bundle install`, run the generator:
76
-
77
- rails generate bootstrap:install static
78
-
79
- ## Generating layouts and views
80
-
81
- You can run following generators to get started with Bootstrap quickly.
82
-
83
-
84
- Layout (generates Bootstrap compatible layout) - (Haml and Slim supported)
85
-
86
-
87
- Usage:
88
-
89
-
90
- rails g bootstrap:layout [LAYOUT_NAME]
91
-
92
-
93
- Themed (generates Bootstrap compatible scaffold views.) - (Haml and Slim supported)
94
-
95
-
96
- Usage:
97
-
98
-
99
- rails g bootstrap:themed [RESOURCE_NAME]
100
-
101
-
102
- Example:
103
-
104
-
105
- rails g scaffold Post title:string description:text
106
- rake db:migrate
107
- rails g bootstrap:themed Posts
108
-
109
- Notice the plural usage of the resource to generate bootstrap:themed.
110
-
111
- ## Using with Less
112
-
113
- Bootstrap was built with Preboot, an open-source pack of mixins and variables to be used in conjunction with Less, a CSS preprocessor for faster and easier web development.
114
-
115
- ## Using stylesheets with Less
116
-
117
- You have to require Bootstrap LESS (bootstrap_and_overrides.css.less) in your application.css
118
-
119
- ```css
120
- /*
121
- *= require bootstrap_and_overrides
122
- */
123
-
124
- /* Your stylesheets goes here... */
125
- ```
126
-
127
- To use individual components from bootstrap, your bootstrap_and_overrides.less could look like this:
128
-
129
- ```less
130
- // Core variables and mixins
131
- @import "twitter/bootstrap/variables.less";
132
- @import "twitter/bootstrap/mixins.less";
133
-
134
- // Reset and dependencies
135
- @import "twitter/bootstrap/normalize.less";
136
- @import "twitter/bootstrap/print.less";
137
- //@import "twitter/bootstrap/glyphicons.less"; // Excludes glyphicons
138
-
139
- // Core CSS
140
- @import "twitter/bootstrap/scaffolding.less";
141
- @import "twitter/bootstrap/type.less";
142
- @import "twitter/bootstrap/code.less";
143
- @import "twitter/bootstrap/grid.less";
144
- @import "twitter/bootstrap/tables.less";
145
- @import "twitter/bootstrap/forms.less";
146
- @import "twitter/bootstrap/buttons.less";
147
-
148
- // Components
149
- @import "twitter/bootstrap/component-animations.less";
150
- @import "twitter/bootstrap/dropdowns.less";
151
- @import "twitter/bootstrap/button-groups.less";
152
- @import "twitter/bootstrap/input-groups.less";
153
- @import "twitter/bootstrap/navs.less";
154
- @import "twitter/bootstrap/navbar.less";
155
- @import "twitter/bootstrap/breadcrumbs.less";
156
- @import "twitter/bootstrap/pagination.less";
157
- @import "twitter/bootstrap/pager.less";
158
- @import "twitter/bootstrap/labels.less";
159
- @import "twitter/bootstrap/badges.less";
160
- @import "twitter/bootstrap/jumbotron.less";
161
- @import "twitter/bootstrap/thumbnails.less";
162
- @import "twitter/bootstrap/alerts.less";
163
- @import "twitter/bootstrap/progress-bars.less";
164
- @import "twitter/bootstrap/media.less";
165
- @import "twitter/bootstrap/list-group.less";
166
- @import "twitter/bootstrap/panels.less";
167
- @import "twitter/bootstrap/responsive-embed.less";
168
- @import "twitter/bootstrap/wells.less";
169
- @import "twitter/bootstrap/close.less";
170
-
171
- // Components w/ JavaScript
172
- @import "twitter/bootstrap/modals.less";
173
- @import "twitter/bootstrap/tooltip.less";
174
- @import "twitter/bootstrap/popovers.less";
175
- @import "twitter/bootstrap/carousel.less";
176
-
177
- // Utility classes
178
- @import "twitter/bootstrap/utilities.less";
179
- @import "twitter/bootstrap/responsive-utilities.less";
180
- ```
181
-
182
- If you'd like to alter Bootstrap's own variables, or define your LESS
183
- styles inheriting Bootstrap's mixins, you can do so inside bootstrap_and_overrides.css.less:
184
-
185
-
186
- ```less
187
- @link-color: #ff0000;
188
- ```
189
-
190
- ### SASS
191
-
192
- If you are using SASS to compile your application.css (e.g. your manifest file is application.css.sass or application.css.scss) you may get this:
193
-
194
- ```
195
- Invalid CSS after "*": expected "{", was "= require twitt..."
196
- (in app/assets/stylesheets/application.css)
197
- (sass)
198
- ```
199
-
200
- If this is the case, you **must** use @import instead of `*=` in your manifest file, or don't compile your manifest with SASS.
201
-
202
- ### Icons
203
-
204
- By default, this gem (when using less generator) won't enable standard Bootstraps's Glyphicons.
205
-
206
- If you would like to restore the default Glyphicons, inside the generated `bootstrap_and_overrides.css.less` uncomment these lines:
207
-
208
- ```less
209
- // Glyphicons are not required by default, uncomment the following lines to enable them.
210
- @glyphiconsEotPath: font-url("glyphicons-halflings-regular.eot");
211
- @glyphiconsEotPath_iefix: font-url("glyphicons-halflings-regular.eot?#iefix");
212
- @glyphiconsWoffPath: font-url("glyphicons-halflings-regular.woff");
213
- @glyphiconsTtfPath: font-url("glyphicons-halflings-regular.ttf");
214
- @glyphiconsSvgPath: font-url("glyphicons-halflings-regular.svg#glyphicons_halflingsregular");
215
-
216
- @import "twitter/bootstrap/glyphicons.less";
217
- ```
218
-
219
- This gem was used to bundle the excellent [Font-Awesome](http://fortawesome.github.io/Font-Awesome/) library.
220
- However that was another maintenance effort that is not worth to do here.
221
-
222
- For Rails projects that need it there is the [font-awesome-rails gem](https://github.com/bokmann/font-awesome-rails) that
223
- provides same functionality that this gems was used to provide and it also have some other interesting features (e.g. view helpers).
224
-
225
- ## Using JavaScript
226
-
227
- Require Bootstrap JS (bootstrap.js) in your application.js
228
-
229
- ```js
230
- //= require twitter/bootstrap
231
-
232
- $(function(){
233
- /* Your JavaScript goes here... */
234
- });
235
- ```
236
-
237
- If you want to customize what is loaded, your application.js would look something like this
238
-
239
- ```js
240
- #= require jquery
241
- #= require jquery_ujs
242
- #= require twitter/bootstrap/transition
243
- #= require twitter/bootstrap/alert
244
- #= require twitter/bootstrap/modal
245
- #= require twitter/bootstrap/button
246
- #= require twitter/bootstrap/collapse
247
- ```
248
-
249
- ...and so on for each bootstrap js component.
250
-
251
- ## Using CoffeeScript (optionally)
252
-
253
- Using Bootstrap with the CoffeeScript is easy.
254
- twitter-bootstrap-rails generates a "bootstrap.js.coffee" file for you
255
- to /app/assets/javascripts/ folder.
256
-
257
- ```coffee
258
- jQuery ->
259
- $("a[rel~=popover], .has-popover").popover()
260
- $("a[rel~=tooltip], .has-tooltip").tooltip()
261
- ```
262
-
263
- ## Using Helpers
264
-
265
- ### Modal Helper
266
- You can create modals easily using the following example. The header, body, and footer all accept content_tag or plain html.
267
- The href of the button to launch the modal must match the id of the modal dialog. It also accepts a block for the header, body, and footer. If you are getting a complaint about the modal_helper unable to merge a hash it is due to this.
268
-
269
- ```erb
270
- <%= content_tag :a, "Modal", href: "#modal", class: 'btn', data: {toggle: 'modal'} %>
271
-
272
- <%= modal_dialog id: "modal",
273
- header: { show_close: true, dismiss: 'modal', title: 'Modal header' },
274
- body: { content: 'This is the body' },
275
- footer: { content: content_tag(:button, 'Save', class: 'btn') } %>
276
-
277
- ```
278
-
279
- ### Navbar Helper
280
- It should let you write things like:
281
-
282
- ```erb
283
- <%= nav_bar fixed: :top, brand: "Fashionable Clicheizr 2.0", responsive: true do %>
284
- <%= menu_group do %>
285
- <%= menu_item "Home", root_path %>
286
- <%= menu_divider %>
287
- <%= drop_down "Products" do %>
288
- <%= menu_item "Things you can't afford", expensive_products_path %>
289
- <%= menu_item "Things that won't suit you anyway", harem_pants_path %>
290
- <%= menu_item "Things you're not even cool enough to buy anyway", hipster_products_path %>
291
- <% if current_user.lives_in_hackney? %>
292
- <%= menu_item "Bikes", fixed_wheel_bikes_path %>
293
- <% end %>
294
- <% end %>
295
- <%= menu_item "About Us", about_us_path %>
296
- <%= menu_item "Contact", contact_path %>
297
- <% end %>
298
- <%= menu_group pull: :right do %>
299
- <% if current_user %>
300
- <%= menu_item "Log Out", log_out_path %>
301
- <% else %>
302
- <%= form_for @user, url: session_path(:user), html => {class: "navbar-form pull-right"} do |f| -%>
303
- <p><%= f.text_field :email %></p>
304
- <p><%= f.password_field :password %></p>
305
- <p><%= f.submit "Sign in" %></p>
306
- <% end -%>
307
- <% end %>
308
- <% end %>
309
- <% end %>
310
- ```
311
-
312
- ### Navbar scaffolding
313
-
314
- In your view file (most likely application.html.erb) to get a basic navbar set up you need to do this:
315
-
316
- ```erb
317
- <%= nav_bar %>
318
- ```
319
-
320
- Which will render:
321
-
322
- ```html
323
- <div class="navbar">
324
- <div class="container">
325
- </div>
326
- </div>
327
- ```
328
-
329
- ### Fixed navbar
330
-
331
- If you want the navbar to stick to the top of the screen, pass in the option like this:
332
-
333
- ```erb
334
- <%= nav_bar fixed: :top %>
335
- ```
336
-
337
- To render:
338
-
339
- ```html
340
- <div class="navbar navbar-fixed-top">
341
- <div class="container">
342
- </div>
343
- </div>
344
- ```
345
-
346
- ### Static navbar
347
-
348
- If you want a full-width navbar that scrolls away with the page, pass in the option like this:
349
-
350
- ```erb
351
- <%= nav_bar static: :top %>
352
- ```
353
-
354
- To render:
355
-
356
- ```html
357
- <div class="navbar navbar-static-top">
358
- <div class="container">
359
- </div>
360
- </div>
361
- ```
362
-
363
- ### Brand name
364
-
365
- Add the name of your site on the left hand edge of the navbar. By default, it will link to root_url. Passing a brand_link option will set the url to whatever you want.
366
-
367
- ```erb
368
- <%= nav_bar brand: "We're sooo web 2.0alizr", brand_link: account_dashboard_path %>
369
- ```
370
-
371
- Which will render:
372
-
373
- ```html
374
- <div class="navbar">
375
- <div class="container">
376
- <a class="navbar-brand" href="/accounts/dashboard">
377
- We're sooo web 2.0alizr
378
- </a>
379
- </div>
380
- </div>
381
- ```
382
-
383
- ### Optional responsive variation
384
-
385
- If you want the responsive version of the navbar to work (One that shrinks down on mobile devices etc.), you need to pass this option:
386
-
387
- ```erb
388
- <%= nav_bar responsive: true %>
389
- ```
390
-
391
- Which renders the html quite differently:
392
-
393
- ```html
394
- <div class="navbar">
395
- <div class="container">
396
- <!-- .navbar-toggle is used as the toggle for collapsed navbar content -->
397
- <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
398
- <span class="icon-bar"></span>
399
- <span class="icon-bar"></span>
400
- <span class="icon-bar"></span>
401
- </button>
402
- <!-- Everything in here gets hidden at 940px or less -->
403
- <div class="navbar-collapse collapse">
404
- <!-- menu items gets rendered here instead -->
405
- </div>
406
- </div>
407
- </div>
408
- ```
409
-
410
- ### Nav links
411
-
412
- This is the 'meat' of the code where you define your menu items.
413
-
414
- You can group menu items in theoretical boxes which you can apply logic to - e.g. show different collections for logged in users/logged out users, or simply right align a group.
415
-
416
- The active menu item will be inferred from the link for now.
417
-
418
- The important methods here are menu_group and menu_item.
419
-
420
- menu_group only takes one argument - :pull - this moves the group left or right when passed :left or :right.
421
-
422
- menu_item generates a link wrapped in an li tag. It takes two arguments and an options hash. The first argument is the name (the text that will appear in the menu), and the path (which defaults to "#" if left blank). The rest of the options are passed straight through to the link_to helper, so that you can add classes, ids, methods or data tags etc.
423
-
424
- ```erb
425
- <%= nav_bar fixed: :top, brand: "Ninety Ten" do %>
426
- <%= menu_group do %>
427
- <%= menu_item "Home", root_path %>
428
- <%= menu_item "About Us", about_us_path %>
429
- <%= menu_item "Contact", contact_path %>
430
- <% end %>
431
- <% if current_user %>
432
- <%= menu_item "Log Out", log_out_path %>
433
- <% else %>
434
- <%= menu_group pull: :right do %>
435
- <%= menu_item "Sign Up", registration_path %>
436
- <%= form_for @user, url: session_path(:user) do |f| -%>
437
- <p><%= f.text_field :email %></p>
438
- <p><%= f.password_field :password %></p>
439
- <p><%= f.submit "Sign in" %></p>
440
- <% end -%>
441
- <% end %>
442
- <% end %>
443
- <% end %>
444
- ```
445
-
446
- ### Dropdown menus
447
-
448
- For multi-level list options, where it makes logical sense to group menu items, or simply to save space if you have a lot of pages, you can group menu items into drop down lists like this:
449
-
450
- ```erb
451
- <%= nav_bar do %>
452
- <%= menu_item "Home", root_path %>
453
-
454
- <%= drop_down "Products" do %>
455
- <%= menu_item "Latest", latest_products_path %>
456
- <%= menu_item "Top Sellers", popular_products_path %>
457
- <%= drop_down_divider %>
458
- <%= menu_item "Discount Items", discounted_products_path %>
459
- <% end %>
460
-
461
- <%= menu_item "About Us", about_us_path %>
462
- <%= menu_item "Contact", contact_path %>
463
- <% end %>
464
- ```
465
-
466
- ### Dividers
467
-
468
- Dividers are just vertical bars that visually separate logically disparate groups of menu items
469
-
470
- ```erb
471
- <%= nav_bar fixed: :bottom do %>
472
- <%= menu_item "Home", root_path %>
473
- <%= menu_item "About Us", about_us_path %>
474
- <%= menu_item "Contact", contact_path %>
475
-
476
- <%= menu_divider %>
477
-
478
- <%= menu_item "Edit Profile", edit_user_path(current_user) %>
479
- <%= menu_item "Account Settings", edit_user_account_path(current_user, @account) %>
480
- <%= menu_item "Log Out", log_out_path %>
481
- <% end %>
482
- ```
483
-
484
- ### Forms in navbar
485
-
486
- At the moment - this is just a how to...
487
-
488
- You need to add this class to the form itself (Different form builders do this in different ways - please check out the relevant docs)
489
-
490
- ```css
491
- .navbar-form
492
- ```
493
- To pull the form left or right, add either of these classes:
494
- ```css
495
- .pull-left
496
- .pull-right
497
- ```
498
-
499
- If you want the Bootstrap search box (I think it just rounds the corners), use:
500
- ```css
501
- .navbar-search
502
- ```
503
- Instead of:
504
- ```css
505
- .navbar-form
506
- ```
507
-
508
- To change the size of the form fields, use .span2 (or however many span widths you want) to the input itself.
509
-
510
- ### Component alignment
511
-
512
- You can shift things to the left or the right across the nav bar. It's easiest to do this on grouped menu items:
513
-
514
- ```erb
515
- <%= nav_bar fixed: :bottom do %>
516
- <% menu_group do %>
517
- <%= menu_item "Home", root_path %>
518
- <%= menu_item "About Us", about_us_path %>
519
- <%= menu_item "Contact", contact_path %>
520
- <% end %>
521
- <% menu_group pull: :right do %>
522
- <%= menu_item "Edit Profile", edit_user_path(current_user) %>
523
- <%= menu_item "Account Settings", edit_user_account_path(current_user, @account) %>
524
- <%= menu_item "Log Out", log_out_path %>
525
- <% end %>
526
- <% end %>
527
- ```
528
-
529
- ### Text in the navbar
530
-
531
- If you want to put regular plain text in the navbar anywhere, you do it like this:
532
-
533
- ```erb
534
- <%= nav_bar brand: "Apple" do %>
535
- <%= menu_text "We make shiny things" %>
536
- <%= menu_item "Home", root_path %>
537
- <%= menu_item "About Us", about_us_path %>
538
- <% end %>
539
- ```
540
-
541
- It also takes the :pull option to drag it to the left or right.
542
-
543
- ### Flash helper
544
-
545
- Add flash helper `<%= bootstrap_flash %>` to your layout (built-in with layout generator).
546
- You can pass the attributes you want to add to the main div returned: `<%= bootstrap_flash(class: "extra-class", id: "your-id") %>`
547
-
548
-
549
- ### Breadcrumbs Helpers
550
-
551
- *Notice* If your application is using [breadcrumbs-on-rails](https://github.com/weppos/breadcrumbs_on_rails) you will have a namespace collision with the add_breadcrumb method. For this reason if breadcrumbs-on-rails is detected in `Gemfile` gem methods will be accessible using `boostrap` prefix, i.e. `render_bootstrap_breadcrumbs` and `add_bootstrap_breadcrumb`
552
-
553
- Usually you do not need to use these breadcrumb gems since this gem provides the same functionality out of the box without the additional dependency.
554
-
555
- However if there are some `breadcrumbs-on-rails` features you need to keep you can still use them and use this gem with the prefixes explained above.
556
-
557
- Add breadcrumbs helper `<%= render_breadcrumbs %>` to your layout.
558
- You can also specify a divider for it like this: `<%= render_breadcrumbs('>') %>` (default divider is `/`).
559
- If you do not need dividers at all you can use `nil`: `<%= render_breadcrumbs(nil) %>`.
560
-
561
- Full example:
562
- ```ruby
563
-
564
- render_breadcrumbs(" / ", { class: '', item_class: '', divider_class: '', active_class: 'active' })
565
-
566
- ```
567
-
568
- ```ruby
569
- class ApplicationController
570
- add_breadcrumb :root # 'root_path' will be used as url
571
- end
572
- ```
573
-
574
- ```ruby
575
- class ExamplesController < ApplicationController
576
- add_breadcrumb :index, :examples_path
577
-
578
- def edit
579
- @example = Example.find params[:id]
580
- add_breadcrumb @example # @example.to_s as name, example_path(@example) as url
581
- add_breadcrumb :edit, edit_example_path(@example)
582
- end
583
- end
584
- ```
585
- All symbolic names translated with I18n. See [I18n Internationalization Support](#i18n-internationalization-support)
586
- section.
587
-
588
- ### Element utility helpers
589
-
590
- Badge:
591
- ```erb
592
- <%= badge(12, :warning) %> <span class="badge badge-warning">12</span>
593
- ```
594
-
595
- Label:
596
- ```erb
597
- <%= tag_label('Gut!', :success) %> <span class="label label-success">Gut!</span>
598
- ```
599
-
600
- Glyph:
601
- ```erb
602
- <%= glyph(:pencil) %> <i class="icon-pencil"></i>
603
-
604
- <%= glyph(:pencil, {tag: :span}) %> <span class="icon-pencil"></span>
605
-
606
- <%= glyph(:pencil, {class: 'foo'}) %> <i class="icon-pencil foo"></i>
607
- ```
608
-
609
- ### I18n Internationalization Support
610
- The installer creates an English translation file for you and copies it to config/locales/en.bootstrap.yml
611
-
612
-
613
- NOTE: If you are using Devise in your project, you must have a devise locale file
614
- for handling flash messages, even if those messages are blank. See https://github.com/plataformatec/devise/wiki/I18n
615
-
616
- ## Changelog
617
- Please see CHANGELOG.md for more details
618
-
619
- ## Contributors & Patches & Forks
620
- Please see CONTRIBUTERS.md for contributors list
621
-
622
- ## About Me
623
- Senior Software Developer
624
- Istanbul / Turkey
625
-
626
- ### Contact me
627
- Seyhun Akyürek - seyhunak [at] gmail com
628
-
629
- ## Thanks
630
- Bootstrap and all twitter-bootstrap-rails contributors
631
- http://twbs.github.io/bootstrap
632
-
633
- ## License
634
- Copyright (c) 2017 (since 2012) by Seyhun Akyürek
635
-
636
- 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:
637
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
638
- 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.
1
+ # twitter-bootstrap-rails
2
+
3
+ Bootstrap is a toolkit from Twitter designed to kickstart development of web apps and sites. It includes base CSS and HTML for typography, forms, buttons, tables, grids, navigation, and more.
4
+
5
+ twitter-bootstrap-rails project integrates Bootstrap CSS toolkit for Rails Asset Pipeline (Rails 8, Rails 7, Rails 6, Rails 5 and Rails 4.x versions are supported)
6
+
7
+ [![Gem Version](https://badge.fury.io/rb/twitter-bootstrap-rails.svg)](http://badge.fury.io/rb/twitter-bootstrap-rails)
8
+ [![Dependency Status](https://gemnasium.com/seyhunak/twitter-bootstrap-rails.svg?travis)](https://gemnasium.com/seyhunak/twitter-bootstrap-rails?travis)
9
+ [![Code Climate](https://codeclimate.com/github/seyhunak/twitter-bootstrap-rails/badges/gpa.svg)](https://codeclimate.com/github/seyhunak/twitter-bootstrap-rails?branch=master)
10
+ [![Coverage Status](https://coveralls.io/repos/seyhunak/twitter-bootstrap-rails/badge.svg?branch=master)](https://coveralls.io/repos/seyhunak/twitter-bootstrap-rails/badge.svg?branch=master)
11
+ [![GitHub stars](https://img.shields.io/github/stars/seyhunak/twitter-bootstrap-rails.svg)](https://github.com/seyhunak/twitter-bootstrap-rails/stargazers)
12
+ [![GitHub forks](https://img.shields.io/github/forks/seyhunak/twitter-bootstrap-rails.svg)](https://github.com/seyhunak/twitter-bootstrap-rails/network)
13
+ [![GitHub issues](https://img.shields.io/github/issues/seyhunak/twitter-bootstrap-rails.svg)](https://github.com/seyhunak/twitter-bootstrap-rails/issues)
14
+
15
+ [![OpenCollective](https://opencollective.com/twitter-bootstrap-rails/backers/badge.svg)](#backers)
16
+ [![OpenCollective](https://opencollective.com/twitter-bootstrap-rails/sponsors/badge.svg)](#sponsors)
17
+
18
+ ## Screencasts
19
+ #### Installing twitter-bootstrap-rails, generators, usage and more
20
+
21
+ Screencasts provided by <a href="http://railscasts.com">RailsCasts</a> (Ryan Bates)
22
+
23
+ [Twitter Bootstrap Basics](http://railscasts.com/episodes/328-twitter-bootstrap-basics "Twitter Bootstrap Basics")
24
+ in this episode you will learn how to include Bootstrap into Rails application with the twitter-bootstrap-rails gem.
25
+
26
+ [More on Twitter Bootstrap](http://railscasts.com/episodes/329-more-on-twitter-bootstrap "More on Twitter Bootstrap")
27
+ in this episode continues on the Bootstrap project showing how to display flash messages, add form validations with SimpleForm, customise layout with variables, and switch to using Sass.
28
+ (Note: This episode is pro episode)
29
+
30
+ ## Installing the Gem
31
+
32
+ The [Twitter Bootstrap Rails gem](http://rubygems.org/gems/twitter-bootstrap-rails) can provide the Bootstrap stylesheets in two ways.
33
+
34
+ The plain CSS way is how Bootstrap is provided on [the official website](http://twbs.github.io/bootstrap/).
35
+
36
+ The [Less](http://lesscss.org/) way provides more customisation options, like changing theme colors and provides useful Less mixins for your code, but requires the
37
+ Less gem and the Ruby Racer Javascript runtime (not available on Microsoft Windows).
38
+
39
+ ### Installing the Less stylesheets
40
+
41
+ To use Less stylesheets, you'll need the [less-rails gem](http://rubygems.org/gems/less-rails), and one of [JavaScript runtimes supported by CommonJS](https://github.com/cowboyd/commonjs.rb#supported-runtimes).
42
+
43
+ Include these lines in the Gemfile to install the gems from [RubyGems.org](http://rubygems.org):
44
+
45
+ ```ruby
46
+ gem "therubyracer"
47
+ gem "less-rails" #Sprockets (what Rails 3.1 uses for its asset pipeline) supports LESS
48
+ gem "twitter-bootstrap-rails"
49
+ ```
50
+
51
+ or you can install from latest build;
52
+
53
+ ```ruby
54
+ gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git'
55
+ ```
56
+
57
+ Then run `bundle install` from the command line:
58
+
59
+ bundle install
60
+
61
+ Then run the bootstrap generator to add Bootstrap includes into your assets:
62
+
63
+ rails generate bootstrap:install less
64
+
65
+ If you need to skip coffeescript replacement into app generators, use:
66
+
67
+ rails generate bootstrap:install --no-coffeescript
68
+
69
+ ### Installing the CSS stylesheets
70
+
71
+ If you don't need to customize the stylesheets using Less, the only gem you need is the `twitter-bootstrap-rails` gem:
72
+
73
+ ```ruby
74
+ gem "twitter-bootstrap-rails"
75
+ ```
76
+
77
+ After running `bundle install`, run the generator:
78
+
79
+ rails generate bootstrap:install static
80
+
81
+ If your Rails server is running, make sure to restart it.
82
+
83
+ ## Generating layouts and views
84
+
85
+ You can run following generators to get started with Bootstrap quickly.
86
+
87
+
88
+ Layout (generates Bootstrap compatible layout) - (Haml and Slim supported)
89
+
90
+
91
+ Usage:
92
+
93
+
94
+ rails g bootstrap:layout [LAYOUT_NAME]
95
+
96
+
97
+ Themed (generates Bootstrap compatible scaffold views.) - (Haml and Slim supported)
98
+
99
+
100
+ Usage:
101
+
102
+
103
+ rails g bootstrap:themed [RESOURCE_NAME]
104
+
105
+
106
+ Example:
107
+
108
+
109
+ rails g scaffold Post title:string description:text
110
+ rake db:migrate
111
+ rails g bootstrap:themed Posts
112
+
113
+ Notice the plural usage of the resource to generate bootstrap:themed.
114
+
115
+ ## Using with Less
116
+
117
+ Bootstrap was built with Preboot, an open-source pack of mixins and variables to be used in conjunction with Less, a CSS preprocessor for faster and easier web development.
118
+
119
+ ## Using stylesheets with Less
120
+
121
+ You have to require Bootstrap LESS (bootstrap_and_overrides.css.less) in your application.css
122
+
123
+ ```css
124
+ /*
125
+ *= require bootstrap_and_overrides
126
+ */
127
+
128
+ /* Your stylesheets goes here... */
129
+ ```
130
+
131
+ To use individual components from bootstrap, your bootstrap_and_overrides.less could look like this:
132
+
133
+ ```less
134
+ // Core variables and mixins
135
+ @import "twitter/bootstrap/variables.less";
136
+ @import "twitter/bootstrap/mixins.less";
137
+
138
+ // Reset and dependencies
139
+ @import "twitter/bootstrap/normalize.less";
140
+ @import "twitter/bootstrap/print.less";
141
+ //@import "twitter/bootstrap/glyphicons.less"; // Excludes glyphicons
142
+
143
+ // Core CSS
144
+ @import "twitter/bootstrap/scaffolding.less";
145
+ @import "twitter/bootstrap/type.less";
146
+ @import "twitter/bootstrap/code.less";
147
+ @import "twitter/bootstrap/grid.less";
148
+ @import "twitter/bootstrap/tables.less";
149
+ @import "twitter/bootstrap/forms.less";
150
+ @import "twitter/bootstrap/buttons.less";
151
+
152
+ // Components
153
+ @import "twitter/bootstrap/component-animations.less";
154
+ @import "twitter/bootstrap/dropdowns.less";
155
+ @import "twitter/bootstrap/button-groups.less";
156
+ @import "twitter/bootstrap/input-groups.less";
157
+ @import "twitter/bootstrap/navs.less";
158
+ @import "twitter/bootstrap/navbar.less";
159
+ @import "twitter/bootstrap/breadcrumbs.less";
160
+ @import "twitter/bootstrap/pagination.less";
161
+ @import "twitter/bootstrap/pager.less";
162
+ @import "twitter/bootstrap/labels.less";
163
+ @import "twitter/bootstrap/badges.less";
164
+ @import "twitter/bootstrap/jumbotron.less";
165
+ @import "twitter/bootstrap/thumbnails.less";
166
+ @import "twitter/bootstrap/alerts.less";
167
+ @import "twitter/bootstrap/progress-bars.less";
168
+ @import "twitter/bootstrap/media.less";
169
+ @import "twitter/bootstrap/list-group.less";
170
+ @import "twitter/bootstrap/panels.less";
171
+ @import "twitter/bootstrap/responsive-embed.less";
172
+ @import "twitter/bootstrap/wells.less";
173
+ @import "twitter/bootstrap/close.less";
174
+
175
+ // Components w/ JavaScript
176
+ @import "twitter/bootstrap/modals.less";
177
+ @import "twitter/bootstrap/tooltip.less";
178
+ @import "twitter/bootstrap/popovers.less";
179
+ @import "twitter/bootstrap/carousel.less";
180
+
181
+ // Utility classes
182
+ @import "twitter/bootstrap/utilities.less";
183
+ @import "twitter/bootstrap/responsive-utilities.less";
184
+ ```
185
+
186
+ If you'd like to alter Bootstrap's own variables, or define your LESS
187
+ styles inheriting Bootstrap's mixins, you can do so inside bootstrap_and_overrides.css.less:
188
+
189
+
190
+ ```less
191
+ @link-color: #ff0000;
192
+ ```
193
+
194
+ ### SASS
195
+
196
+ If you are using SASS to compile your application.css (e.g. your manifest file is application.css.sass or application.css.scss) you may get this:
197
+
198
+ ```
199
+ Invalid CSS after "*": expected "{", was "= require twitt..."
200
+ (in app/assets/stylesheets/application.css)
201
+ (sass)
202
+ ```
203
+
204
+ If this is the case, you **must** use @import instead of `*=` in your manifest file, or don't compile your manifest with SASS.
205
+
206
+ ### Icons
207
+
208
+ By default, this gem (when using less generator) won't enable standard Bootstraps's Glyphicons.
209
+
210
+ If you would like to restore the default Glyphicons, inside the generated `bootstrap_and_overrides.css.less` uncomment these lines:
211
+
212
+ ```less
213
+ // Glyphicons are not required by default, uncomment the following lines to enable them.
214
+ @glyphiconsEotPath: font-url("glyphicons-halflings-regular.eot");
215
+ @glyphiconsEotPath_iefix: font-url("glyphicons-halflings-regular.eot?#iefix");
216
+ @glyphiconsWoffPath: font-url("glyphicons-halflings-regular.woff");
217
+ @glyphiconsTtfPath: font-url("glyphicons-halflings-regular.ttf");
218
+ @glyphiconsSvgPath: font-url("glyphicons-halflings-regular.svg#glyphicons_halflingsregular");
219
+
220
+ @import "twitter/bootstrap/glyphicons.less";
221
+ ```
222
+
223
+ This gem was used to bundle the excellent [Font-Awesome](http://fortawesome.github.io/Font-Awesome/) library.
224
+ However that was another maintenance effort that is not worth to do here.
225
+
226
+ For Rails projects that need it there is the [font-awesome-rails gem](https://github.com/bokmann/font-awesome-rails) that
227
+ provides same functionality that this gems was used to provide and it also have some other interesting features (e.g. view helpers).
228
+
229
+ ## Using JavaScript
230
+
231
+ Require Bootstrap JS (bootstrap.js) in your application.js
232
+
233
+ ```js
234
+ //= require twitter/bootstrap
235
+
236
+ $(function(){
237
+ /* Your JavaScript goes here... */
238
+ });
239
+ ```
240
+
241
+ If you want to customize what is loaded, your application.js would look something like this
242
+
243
+ ```js
244
+ #= require jquery
245
+ #= require jquery_ujs
246
+ #= require twitter/bootstrap/transition
247
+ #= require twitter/bootstrap/alert
248
+ #= require twitter/bootstrap/modal
249
+ #= require twitter/bootstrap/button
250
+ #= require twitter/bootstrap/collapse
251
+ ```
252
+
253
+ ...and so on for each bootstrap js component.
254
+
255
+ ## Using CoffeeScript (optionally)
256
+
257
+ Using Bootstrap with the CoffeeScript is easy.
258
+ twitter-bootstrap-rails generates a "bootstrap.js.coffee" file for you
259
+ to /app/assets/javascripts/ folder.
260
+
261
+ ```coffee
262
+ jQuery ->
263
+ $("a[rel~=popover], .has-popover").popover()
264
+ $("a[rel~=tooltip], .has-tooltip").tooltip()
265
+ ```
266
+
267
+ ## Using Helpers
268
+
269
+ ### Modal Helper
270
+ You can create modals easily using the following example. The header, body, and footer all accept content_tag or plain html.
271
+ The href of the button to launch the modal must match the id of the modal dialog. It also accepts a block for the header, body, and footer. If you are getting a complaint about the modal_helper unable to merge a hash it is due to this.
272
+
273
+ ```erb
274
+ <%= content_tag :a, "Modal", href: "#modal", class: 'btn', data: {toggle: 'modal'} %>
275
+ <%= modal_dialog id: "modal",
276
+ header: { show_close: true, dismiss: 'modal', title: 'Modal header' },
277
+ body: { content: 'This is the body' },
278
+ footer: { content: content_tag(:button, 'Save', class: 'btn') } %>
279
+ ```
280
+
281
+ ### Navbar Helper
282
+ It should let you write things like:
283
+
284
+ ```erb
285
+ <%= nav_bar fixed: :top, brand: "Fashionable Clicheizr 2.0", responsive: true do %>
286
+ <%= menu_group do %>
287
+ <%= menu_item "Home", root_path %>
288
+ <%= menu_divider %>
289
+ <%= drop_down "Products" do %>
290
+ <%= menu_item "Things you can't afford", expensive_products_path %>
291
+ <%= menu_item "Things that won't suit you anyway", harem_pants_path %>
292
+ <%= menu_item "Things you're not even cool enough to buy anyway", hipster_products_path %>
293
+ <% if current_user.lives_in_hackney? %>
294
+ <%= menu_item "Bikes", fixed_wheel_bikes_path %>
295
+ <% end %>
296
+ <% end %>
297
+ <%= menu_item "About Us", about_us_path %>
298
+ <%= menu_item "Contact", contact_path %>
299
+ <% end %>
300
+ <%= menu_group pull: :right do %>
301
+ <% if current_user %>
302
+ <%= menu_item "Log Out", log_out_path %>
303
+ <% else %>
304
+ <%= form_for @user, url: session_path(:user), html => {class: "navbar-form pull-right"} do |f| -%>
305
+ <p><%= f.text_field :email %></p>
306
+ <p><%= f.password_field :password %></p>
307
+ <p><%= f.submit "Sign in" %></p>
308
+ <% end -%>
309
+ <% end %>
310
+ <% end %>
311
+ <% end %>
312
+ ```
313
+
314
+ ### Navbar scaffolding
315
+
316
+ In your view file (most likely application.html.erb) to get a basic navbar set up you need to do this:
317
+
318
+ ```erb
319
+ <%= nav_bar %>
320
+ ```
321
+
322
+ Which will render:
323
+
324
+ ```html
325
+ <div class="navbar">
326
+ <div class="container">
327
+ </div>
328
+ </div>
329
+ ```
330
+
331
+ ### Fixed navbar
332
+
333
+ If you want the navbar to stick to the top of the screen, pass in the option like this:
334
+
335
+ ```erb
336
+ <%= nav_bar fixed: :top %>
337
+ ```
338
+
339
+ To render:
340
+
341
+ ```html
342
+ <div class="navbar navbar-fixed-top">
343
+ <div class="container">
344
+ </div>
345
+ </div>
346
+ ```
347
+
348
+ ### Static navbar
349
+
350
+ If you want a full-width navbar that scrolls away with the page, pass in the option like this:
351
+
352
+ ```erb
353
+ <%= nav_bar static: :top %>
354
+ ```
355
+
356
+ To render:
357
+
358
+ ```html
359
+ <div class="navbar navbar-static-top">
360
+ <div class="container">
361
+ </div>
362
+ </div>
363
+ ```
364
+
365
+ ### Brand name
366
+
367
+ Add the name of your site on the left hand edge of the navbar. By default, it will link to root_url. Passing a brand_link option will set the url to whatever you want.
368
+
369
+ ```erb
370
+ <%= nav_bar brand: "We're sooo web 2.0alizr", brand_link: account_dashboard_path %>
371
+ ```
372
+
373
+ Which will render:
374
+
375
+ ```html
376
+ <div class="navbar">
377
+ <div class="container">
378
+ <a class="navbar-brand" href="/accounts/dashboard">
379
+ We're sooo web 2.0alizr
380
+ </a>
381
+ </div>
382
+ </div>
383
+ ```
384
+
385
+ ### Optional responsive variation
386
+
387
+ If you want the responsive version of the navbar to work (One that shrinks down on mobile devices etc.), you need to pass this option:
388
+
389
+ ```erb
390
+ <%= nav_bar responsive: true %>
391
+ ```
392
+
393
+ Which renders the html quite differently:
394
+
395
+ ```html
396
+ <div class="navbar">
397
+ <div class="container">
398
+ <!-- .navbar-toggle is used as the toggle for collapsed navbar content -->
399
+ <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
400
+ <span class="icon-bar"></span>
401
+ <span class="icon-bar"></span>
402
+ <span class="icon-bar"></span>
403
+ </button>
404
+ <!-- Everything in here gets hidden at 940px or less -->
405
+ <div class="navbar-collapse collapse">
406
+ <!-- menu items gets rendered here instead -->
407
+ </div>
408
+ </div>
409
+ </div>
410
+ ```
411
+
412
+ ### Nav links
413
+
414
+ This is the 'meat' of the code where you define your menu items.
415
+
416
+ You can group menu items in theoretical boxes which you can apply logic to - e.g. show different collections for logged in users/logged out users, or simply right align a group.
417
+
418
+ The active menu item will be inferred from the link for now.
419
+
420
+ The important methods here are menu_group and menu_item.
421
+
422
+ menu_group only takes one argument - :pull - this moves the group left or right when passed :left or :right.
423
+
424
+ menu_item generates a link wrapped in an li tag. It takes two arguments and an options hash. The first argument is the name (the text that will appear in the menu), and the path (which defaults to "#" if left blank). The rest of the options are passed straight through to the link_to helper, so that you can add classes, ids, methods or data tags etc.
425
+
426
+ ```erb
427
+ <%= nav_bar fixed: :top, brand: "Ninety Ten" do %>
428
+ <%= menu_group do %>
429
+ <%= menu_item "Home", root_path %>
430
+ <%= menu_item "About Us", about_us_path %>
431
+ <%= menu_item "Contact", contact_path %>
432
+ <% end %>
433
+ <% if current_user %>
434
+ <%= menu_item "Log Out", log_out_path %>
435
+ <% else %>
436
+ <%= menu_group pull: :right do %>
437
+ <%= menu_item "Sign Up", registration_path %>
438
+ <%= form_for @user, url: session_path(:user) do |f| -%>
439
+ <p><%= f.text_field :email %></p>
440
+ <p><%= f.password_field :password %></p>
441
+ <p><%= f.submit "Sign in" %></p>
442
+ <% end -%>
443
+ <% end %>
444
+ <% end %>
445
+ <% end %>
446
+ ```
447
+
448
+ ### Dropdown menus
449
+
450
+ For multi-level list options, where it makes logical sense to group menu items, or simply to save space if you have a lot of pages, you can group menu items into drop down lists like this:
451
+
452
+ ```erb
453
+ <%= nav_bar do %>
454
+ <%= menu_item "Home", root_path %>
455
+ <%= drop_down "Products" do %>
456
+ <%= menu_item "Latest", latest_products_path %>
457
+ <%= menu_item "Top Sellers", popular_products_path %>
458
+ <%= drop_down_divider %>
459
+ <%= menu_item "Discount Items", discounted_products_path %>
460
+ <% end %>
461
+ <%= menu_item "About Us", about_us_path %>
462
+ <%= menu_item "Contact", contact_path %>
463
+ <% end %>
464
+ ```
465
+
466
+ ### Dividers
467
+
468
+ Dividers are just vertical bars that visually separate logically disparate groups of menu items
469
+
470
+ ```erb
471
+ <%= nav_bar fixed: :bottom do %>
472
+ <%= menu_item "Home", root_path %>
473
+ <%= menu_item "About Us", about_us_path %>
474
+ <%= menu_item "Contact", contact_path %>
475
+ <%= menu_divider %>
476
+ <%= menu_item "Edit Profile", edit_user_path(current_user) %>
477
+ <%= menu_item "Account Settings", edit_user_account_path(current_user, @account) %>
478
+ <%= menu_item "Log Out", log_out_path %>
479
+ <% end %>
480
+ ```
481
+
482
+ ### Forms in navbar
483
+
484
+ At the moment - this is just a how to...
485
+
486
+ You need to add this class to the form itself (Different form builders do this in different ways - please check out the relevant docs)
487
+
488
+ ```css
489
+ .navbar-form
490
+ ```
491
+ To pull the form left or right, add either of these classes:
492
+ ```css
493
+ .pull-left
494
+ .pull-right
495
+ ```
496
+
497
+ If you want the Bootstrap search box (I think it just rounds the corners), use:
498
+ ```css
499
+ .navbar-search
500
+ ```
501
+ Instead of:
502
+ ```css
503
+ .navbar-form
504
+ ```
505
+
506
+ To change the size of the form fields, use .span2 (or however many span widths you want) to the input itself.
507
+
508
+ ### Component alignment
509
+
510
+ You can shift things to the left or the right across the nav bar. It's easiest to do this on grouped menu items:
511
+
512
+ ```erb
513
+ <%= nav_bar fixed: :bottom do %>
514
+ <% menu_group do %>
515
+ <%= menu_item "Home", root_path %>
516
+ <%= menu_item "About Us", about_us_path %>
517
+ <%= menu_item "Contact", contact_path %>
518
+ <% end %>
519
+ <% menu_group pull: :right do %>
520
+ <%= menu_item "Edit Profile", edit_user_path(current_user) %>
521
+ <%= menu_item "Account Settings", edit_user_account_path(current_user, @account) %>
522
+ <%= menu_item "Log Out", log_out_path %>
523
+ <% end %>
524
+ <% end %>
525
+ ```
526
+
527
+ ### Text in the navbar
528
+
529
+ If you want to put regular plain text in the navbar anywhere, you do it like this:
530
+
531
+ ```erb
532
+ <%= nav_bar brand: "Apple" do %>
533
+ <%= menu_text "We make shiny things" %>
534
+ <%= menu_item "Home", root_path %>
535
+ <%= menu_item "About Us", about_us_path %>
536
+ <% end %>
537
+ ```
538
+
539
+ It also takes the :pull option to drag it to the left or right.
540
+
541
+ ### Flash helper
542
+
543
+ Add flash helper `<%= bootstrap_flash %>` to your layout (built-in with layout generator).
544
+ You can pass the attributes you want to add to the main div returned: `<%= bootstrap_flash(class: "extra-class", id: "your-id") %>`
545
+
546
+
547
+ ### Breadcrumbs Helpers
548
+
549
+ *Notice* If your application is using [breadcrumbs-on-rails](https://github.com/weppos/breadcrumbs_on_rails) you will have a namespace collision with the add_breadcrumb method. For this reason if breadcrumbs-on-rails is detected in `Gemfile` gem methods will be accessible using `boostrap` prefix, i.e. `render_bootstrap_breadcrumbs` and `add_bootstrap_breadcrumb`
550
+
551
+ Usually you do not need to use these breadcrumb gems since this gem provides the same functionality out of the box without the additional dependency.
552
+
553
+ However if there are some `breadcrumbs-on-rails` features you need to keep you can still use them and use this gem with the prefixes explained above.
554
+
555
+ Add breadcrumbs helper `<%= render_breadcrumbs %>` to your layout.
556
+ You can also specify a divider for it like this: `<%= render_breadcrumbs('>') %>` (default divider is `/`).
557
+ If you do not need dividers at all you can use `nil`: `<%= render_breadcrumbs(nil) %>`.
558
+
559
+ Full example:
560
+ ```ruby
561
+
562
+ render_breadcrumbs(" / ", { class: '', item_class: '', divider_class: '', active_class: 'active' })
563
+
564
+ ```
565
+
566
+ ```ruby
567
+ class ApplicationController
568
+ add_breadcrumb :root # 'root_path' will be used as url
569
+ end
570
+ ```
571
+
572
+ ```ruby
573
+ class ExamplesController < ApplicationController
574
+ add_breadcrumb :index, :examples_path
575
+
576
+ def edit
577
+ @example = Example.find params[:id]
578
+ add_breadcrumb @example # @example.to_s as name, example_path(@example) as url
579
+ add_breadcrumb :edit, edit_example_path(@example)
580
+ end
581
+ end
582
+ ```
583
+ All symbolic names translated with I18n. See [I18n Internationalization Support](#i18n-internationalization-support)
584
+ section.
585
+
586
+ ### Element utility helpers
587
+
588
+ Badge:
589
+ ```erb
590
+ <%= badge(12, :warning) %> <span class="badge badge-warning">12</span>
591
+ ```
592
+
593
+ Label:
594
+ ```erb
595
+ <%= tag_label('Good!', :success) %> <span class="label label-success">Good!</span>
596
+ ```
597
+
598
+ Glyph:
599
+ ```erb
600
+ <%= glyph(:pencil) %> <i class="icon-pencil"></i>
601
+ <%= glyph(:pencil, {tag: :span}) %> <span class="icon-pencil"></span>
602
+ <%= glyph(:pencil, {class: 'foo'}) %> <i class="icon-pencil foo"></i>
603
+ ```
604
+
605
+ ### I18n Internationalization Support
606
+ The installer creates an English translation file for you and copies it to config/locales/en.bootstrap.yml
607
+
608
+
609
+ NOTE: If you are using Devise in your project, you must have a devise locale file
610
+ for handling flash messages, even if those messages are blank. See https://github.com/plataformatec/devise/wiki/I18n
611
+
612
+ ## Changelog
613
+ Please see CHANGELOG.md for more details
614
+
615
+ ## Contributors & Patches & Forks
616
+ Please see CONTRIBUTERS.md for contributors list
617
+
618
+ ## About Me
619
+ Senior Software Developer Istanbul / Turkey
620
+ seyhunak [at] gmail com
621
+
622
+ ## Hire Me
623
+ [![Hire Me !](https://img.shields.io/badge/Hire%20Me-for%20your%20project%20on%20PPH-red?s?style=social&logo=ios&logoColor=blue&labelColor=black&color=blue)](http://pph.me/seyhunak)
624
+
625
+ ## Thanks
626
+ Bootstrap and all twitter-bootstrap-rails contributors
627
+ http://twbs.github.io/bootstrap
628
+
629
+ ## Backers
630
+ Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/twitter-bootstrap-rails#backer)]
631
+
632
+ ## License
633
+ Copyright (c) 2025 (since 2012) by Seyhun Akyürek
634
+
635
+ 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:
636
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
637
+ 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.
638
+