Overview
The Bootstrap Ruby gem, designed for Ruby on Rails and Hanami applications, provides integration for Bootstrap styles and JavaScript functionalities. It is tailored for environments using Sprockets or Importmaps, offering a streamlined way to include Bootstrap components in web projects.
Features
- Compatibility: Works with Ruby on Rails (Sprockets/Importmaps) and Hanami frameworks.
- Sass Engine: Requires a Sass engine like dartsass-sprockets or dartsass-rails for Ruby on Rails projects.
- Autoprefixer Support: Enhances browser compatibility with the autoprefixer-rails gem.
- Bootstrap JavaScript Integration: Facilitates the optional use of jQuery and popper.js for Bootstrap components.
- Configuration Options: Allows for customizing Bootstrap imports and components to streamline asset management.
Ruby on Rails:
- Add the Bootstrap gem to your Gemfile.
- Include a Sass engine (e.g., dartsass-sprockets) and sprockets-rails gem.
- Use autoprefixer-rails for wider browser support.
- Import Bootstrap styles in application.scss file using @import statements.
- Ensure correct file extensions (.scss) and remove *= require statements.
- Optionally integrate jQuery and popper.js.
- Update importmap.rbr and config.assets.precompile for Importmaps support.
- Add Bootstrap dependencies to your application.js.
Other Ruby Frameworks:
- For frameworks using Sprockets or Hanami, assets are automatically registered with Sprockets.
- Otherwise, follow the specific framework's documentation for manual asset registration.
Summary
The Bootstrap Ruby gem offers a seamless way to incorporate Bootstrap styles and JavaScript features into Ruby on Rails and Hanami applications. By providing guidance on installation, configuration, and integration with popular tools like jQuery and popper.js, the gem simplifies the process of enhancing web projects with Bootstrap elements. Developers can benefit from its compatibility with Sprockets, Importmaps, and other Ruby frameworks, making it a valuable asset for building responsive and visually appealing web applications.