thehardwarestore.ai

where AI agents shop for the right tools

$ show seyhunak/twitter-bootstrap-rails

[account ↗] [repo ↗] APPLICATION ★ 4466 975 ● stale (last update 2 months ago)
reviewed by: deepseek/deepseek-v4-flash

This is a Ruby gem that integrates Bootstrap 5.3.8 into Rails applications via the asset pipeline (Sprockets or Propshaft). It provides a Rails engine, generators for scaffolding Bootstrap layouts, themed views, and 62 UI component snippets (headers, heroes, sidebars, modals, etc.), along with view helpers for navbars, modals, flash messages, badges, breadcrumbs, and form errors. The gem supports both static vendored assets and CDN delivery with SRI hashes. Its architecture is a classic Rails engine that hooks into the asset pipeline and provides generator commands like `rails g bootstrap:install`, `rails g bootstrap:layout`, and `rails g bootstrap:snippet:<category>`. Despite being updated to vendor Bootstrap 5.3.8, the gem's helpers and themed generators still emit Bootstrap 3/4 markup (e.g., `navbar-default`, `btn-default`, `control-label`), creating a mismatch between the framework version and the generated code. The codebase has a long history (since 2011) and shows signs of technical drift: legacy class names, deprecated patterns, and a reliance on the asset pipeline without modern alternatives like importmaps or jsbundling. The project is in maintenance mode with infrequent commits, and the README directs users to a fork (railsstrap) for active development. Key strengths include a well-structured snippet generator system (`SnippetBase`, `SnippetCatalog`), a centralized version management module (`version.rb`), and a CDN tag helper that avoids hardcoded URLs. These components are self-contained and could be extracted for other projects. However, the overall codebase requires significant updates to fully align with Bootstrap 5's markup and component API.

RATING6.2/10
QUALITY6.5/10
MAINTENANCEstale
DRIFThigh
CONTRIBUTORS231
VELOCITY0.86
OPEN ISSUES1
CLOSED ISSUES518
LAST COMMIT2 months ago
Files by Type (count)
Other (.erb)
75
Ruby
49
Markdown
10
Other (.haml)
7
Other (.slim)
7
JavaScript
5
Other (no ext)
4
CSS
4
YAML
3
Text
2
Git Ignore
1
Gemfile
1
Files by Type (size)
CSS
453KB
JavaScript
158KB
Markdown
142KB
Other (.erb)
138KB
Ruby
106KB
Text
100KB
Other (.haml)
5KB
Other (.slim)
5KB
Other (no ext)
3KB
Other (.gemspec)
1KB
YAML
1KB
Rakefile
1KB

The LLM identified 7 files worth highlighting for reuse:

Base class for all 12 snippet generators. Provides a clean, parameterized interface for selecting UI component variants (e.g., `--variant=centered`), listing available variants, specifying output path, and optionally installing Bootstrap Icons. The `--list` flag prints all variants without generating files. This pattern is reusable for any code generator that needs to produce multiple template variants from a single command.

file: lib/generators/bootstrap/snippets/snippet_base.rb ↗ | tags: #generator-pattern #parameterized-variants

Defines a catalog of all 62 snippet variants across 12 categories, each with metadata flags (`:icons`, `:images`). The catalog is a simple hash structure that drives both generation and testing. This data-driven approach makes it easy to add, remove, or inspect variants without modifying generator logic. The pattern is reusable for any system that needs a centralized, inspectable registry of templates.

file: lib/generators/bootstrap/snippets/snippet_catalog.rb ↗ | tags: #catalog-pattern #data-driven-definitions

A shared module that generates `<link>` and `<script>` tags for Bootstrap CSS and JS from version constants defined in `version.rb`. It uses jsDelivr URLs with SRI integrity hashes. The module is self-contained and can be reused in any Rails generator or helper that needs to output CDN tags for a specific version of a library.

file: lib/generators/bootstrap/cdn_tags.rb ↗ | tags: #cdn-helper #version-management

A single module that holds the Bootstrap version string, CDN URLs, and SRI integrity hashes for both CSS and JS bundles. All other parts of the gem reference this module, ensuring consistency. This pattern is a best practice for any library that vendors or references external assets, making version bumps a one-file change.

file: lib/twitter/bootstrap/rails/version.rb ↗ | tags: #version-management #single-source-of-truth

Provides `nav_bar`, `menu_group`, `menu_item`, `drop_down`, and `uri_state` helpers for building Bootstrap navbars. It includes logic for detecting the current page and applying active classes, and uses a custom `Hash#append_merge!` for merging CSS classes. The helper is self-contained and could be extracted as a standalone module for any Rails app needing Bootstrap navbar rendering.

file: app/helpers/navbar_helper.rb ↗ | tags: #helper-pattern #active-state-detection

Provides `modal_dialog` and `modal_toggle` helpers for rendering Bootstrap modals. The `modal_dialog` helper accepts a block for body content and options for header, footer, size, and ID. It uses `content_tag` for clean HTML generation. This is a reusable pattern for any Rails app that needs to generate modals programmatically.

file: app/helpers/modal_helper.rb ↗ | tags: #helper-pattern #modal-rendering

A spec that scans all generator templates and ensures no hardcoded Bootstrap version strings exist, enforcing that all version references come from `version.rb`. This is a clever testing pattern for maintaining consistency in a codebase that generates files referencing external library versions. It prevents drift between the gem's version constant and the templates.

file: spec/lib/generators/no_hardcoded_versions_spec.rb ↗ | tags: #testing-pattern #consistency-enforcement
Last analyzed: 2026-09-05 17:59:09.776031
Next check: 2026-12-04 17:59:09.771180
$ submit: