viewcomponent.org - Overview | ViewComponent

Description: A framework for building reusable, testable & encapsulated view components in Ruby on Rails.

Example domain paragraphs

Menu Expand (external link) Document Search Copy Copied Overview How-to guide Getting started Collections Conditional rendering Generators Helpers Instrumentation JavaScript and CSS Lifecycle Previews Slots Templates Testing Translations API reference ViewComponents at GitHub Changelog Code of conduct Compatibility Contributing History Known issues Logo Resources Architectural decisions 1. Record architecture decisions 2. Naming conventions for ViewComponents 3. Polymorphic slots 4. Separate Slot Getters an

Think of ViewComponents as an evolution of the presenter pattern, inspired by React . A ViewComponent is a Ruby object:

class MessageComponent < ViewComponent :: Base erb_template <<- ERB <h1>Hello, <%= @name %>!</h1> ERB def initialize ( name :) @name = name end end Which is instantiated and passed to Rails’ #render :

Links to viewcomponent.org (8)