
Product
Announcing Precomputed Reachability Analysis in Socket
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Simple library for building view components in Ruby on Rails.
Declare a component by name, and define its sections and attributes:
# app/helpers/components_helper.rb
define_component :card, sections: [:body, :footer], attributes: [:title]
Define its structure using a partial view:
# app/views/components/_card.html.haml
.card
%h1= card[:title]
.content
= card[:body]
.footer
= card[:footer]
Use it in your views:
-# app/views/welcome/index.html.haml
= card title: 'A value' do |c|
- c.body do
A block of HAML
= link_to 'My page', my_page_path
- c.footer do
%span Another block of HAML
Add view_components
to your Gemfile:
source 'https://rubygems.org'
gem 'view_components'
Each component is defined by its structure, sections and attributes. To register a component, first invoke define_component
in a view helper, such as components_helper
:
# app/helpers/components_helper.rb
define_component :card, sections: [:body, :footer], attributes: [:title]
The name of the component must be a valid identifier, as well as the sections and the attributes. This gem will then look for a partial view with defined name in the components
views folder; app/views/components/_card.html.haml
in the example.
The partial view will receive a hash as a local variable with the same name as the view (again, card
), which will contain both the values of the attributes and sections.
define_component
will also define a method for your views with the specified name, that can be used as a builder for the component. The content of each block will be captured and inserted in the specified location in the partial view.
Next in the roadmap is adding support for collections, which should act as sections that are inserted multiple times in the component.
FAQs
Unknown package
We found that view_components demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.