A view component library for Ruby and Rails that encapsulates UI parts into reusable, testable view models.
Cells is a view component library for Ruby and Rails that encapsulates UI parts into reusable view models. It solves the problem of messy view logic by providing an object-oriented approach to building and testing UI components, moving beyond traditional Rails helpers and partials.
Ruby on Rails developers building complex UIs who want to improve maintainability, testability, and encapsulation of their view layer.
Developers choose Cells for its clean separation of concerns, encapsulated testing, and powerful features like caching, nesting, and asset packaging, which make UI code more modular and easier to reason about compared to traditional Rails views.
View components for Ruby and Rails.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Cells return plain HTML, allowing isolated testing with any framework like RSpec or MiniTest, and Capybara integration for UI assertions, as shown in the README's testing examples.
Supports per-state caching with configurable expiration and dynamic keys, enabling fine-grained performance optimizations for repetitive UI components, documented in the caching section.
Cells can bundle JavaScript, CSS, and images, integrating with Rails' asset pipeline to create self-contained widgets, reducing dependency on global assets.
Builders allow instantiating different cell classes based on models or options, introducing polymorphism for flexible and dynamic UI rendering without conditional logic in views.
In non-Rails environments, manual inclusion of template engines and helper modules is required, increasing initial configuration effort and potential for errors.
Requires separate gems for different template engines (e.g., cells-erb, cells-haml), which can lead to dependency management issues and version conflicts, as noted in the installation section.
The README admits that using Rails helpers in cells can be problematic, requiring careful inclusion and debugging due to Rails' helper implementation, which may frustrate developers.