Releases: ViewComponent/view_component
4.2.0
-
Fix translation scope resolution in deeply nested component blocks (3+ levels). Translations called inside deeply nested slot blocks using
renders_many/renders_onewere incorrectly resolving to an intermediate component's scope instead of the partial's scope where the block was defined. The fix captures the virtual path at block definition time and restores it during block execution, ensuring translations always resolve relative to where the block was created regardless of nesting depth.Nathaniel Watts
-
Allow
render_inlinewith Nokogiri::HTML5 to parse more arbitrary content including bare table content otherwise illegal fragments like<td>.Jonathan Rochkind
-
Remove known issue from docs as ActiveScaffold is now compatible with ViewComponent.
David Löwenfels
-
Add test to document the current behavior for resolving relative translation keys within partial blocks. When rendering a partial, relative translation keys are resolved relative to the partial's own path rather than the caller’s path. This test ensures that this behavior remains consistent.
Oussama Hilal
-
Allow I18n calls in
render?.23tux
-
ViewComponent now works without
railsandrailtiesgems loaded, enabling compatibility with Bridgetown 2.0.Tom Lord
-
Capture partial block in the component's context, allowing access to the component instance inside the block.
23tux
-
Add
after_compileclass method hook to enable extensions to run logic after component compilation.Jose Solás
-
Fix outdated reference to preview layout configuration in docs.
Lucas Geron
-
Allow ruby-head CI job to fail without failing workflow.
Hakan Ensari
-
Fix bug where error line numbers were incorrect in Rails 8.1.
Joel Hawksley
-
Remove
< 8.2upper bound foractivesupportandactionviewdependencies.Hans Lemuet
-
Test compatibility with Herb/ReActionView.
Joel Hawksley
-
Remove Who Uses ViewComponent section from docs.
Joel Hawksley
4.1.1
-
Add Consultport to list of companies using ViewComponent.
Sebastian Nepote
-
Resolve deprecation warning for
ActiveSupport::Configurable.Simon Fish
-
Make
ViewComponent::VERSIONaccessible to other gems by default.Hans Lemuet
-
Added Reinvented Hospitality to the list of companies using ViewComponent.
Torgil Zechel
3.24.0
4.1.0
-
Add Rails 8.1 support.
Hans Lemuet
-
Add Carwow to list of companies using ViewComponent.
Tom Lord
Full Changelog: v4.0.2...v4.1.0
4.0.2
What's Changed
- Fix double rendering issue for partials that yield by @camertron in #2424
- Share the view context in tests by @camertron in #2410
Full Changelog: v4.0.1...v4.0.2
4.0.1
-
Conditionally add the
ViewComponent::Base#formatmethod back for Rails 7.1 only. -
Compute and check lockfiles into source control.
-
Constrain Rails versions in gemfiles to only allow the patch version to vary, eg.
~> 7.1.0instead of~> 7.1.Cameron Dutro
-
Setup Trusted Publishing to RubyGems to improve software supply chain safety.
Hans Lemuet
4.0.0
Two years after releasing 3.0.0 and almost six years since 1.0.0, we're proud to ship ViewComponent 4. This release marks a shift towards a Long Term Support model for the project, having reached significant feature maturity. While contributions are always welcome, we're unlikely to accept further breaking changes or major feature additions.
Please report any issues at https://github.com/ViewComponent/view_component/issues.
Breaking changes (production)
-
Remove dependency on
ActionView::Base, eliminating the need for capture compatibility patch. In some edge cases, this change may require switching to use thehelpers.proxy. -
Require non-EOL Rails (
>= 7.1.0) and Ruby (>= 3.2.0). -
Remove
render_componentandrendermonkey patch configured withrender_monkey_patch_enabled. -
Remove deprecated
use_helper(s). Useinclude MyHelperorhelpers.proxy instead. -
Support compatibility with
Dry::Initializer. As a result,EmptyOrInvalidInitializerErrorwill no longer be raised. -
Remove default initializer from
ViewComponent::Base. Previously,ViewComponent::Basedefined a catch-all initializer that allowed components without an initializer defined to be passed arbitrary arguments. -
Remove
use_deprecated_instrumentation_nameconfiguration option. Events will always userender.view_componentname. -
Remove unnecessary
#formatmethods that returnednil. -
Remove support for variant names containing
.to be consistent with Rails. -
Rename internal methods to have
__vc_prefix if they shouldn't be used by consumers. Make internal constants private. MakeCollection#components,Slotable#register_polymorphic_slotprivate. Remove unusedComponentErrorclass. -
Use ActionView's
lookup_contextfor picking templates instead of the request format.3.15 added support for using templates that match the request format, that is if
/resource.csvis requested then
ViewComponents would pick_component.csv.erbover_component.html.erb.With this release, the request format is no longer considered and instead ViewComponent will use the Rails logic for picking the most appropriate template type, that is the csv template will be used if it matches the
Acceptheader or because the controller uses arespond_toblock to pick the response format.
Breaking changes (dev/test)
-
Remove
config.view_component.test_controllerin favor ofvc_test_controller_classtest helper method. -
config.view_component.component_parent_classis nowconfig.view_component.generate.parent_class, moving the generator-specific option to the generator configuration namespace. -
config.view_component.view_component_pathis nowconfig.view_component.generate.path, as components have long since been able to exist in any directory. -
Move previews-related configuration (
enabled,route,paths,default_layout,controller) to underpreviewsnamespace. -
--inlinegenerator option now generates inline template. Use--callto generate#callmethod. -
Remove broken integration with
rails statsthat ignored components outside ofapp/components. -
Remove
preview_sourcefunctionality. Consider using Lookbook instead. -
Use
Nokogiri::HTML5instead ofNokogiri::HTML4for test helpers. -
Move generators to a ViewComponent namespace.
Before, ViewComponent generators pollute the generator namespace with a bunch of top level items, and claim the generic "component" name.
Now, generators live in a "view_component" module/namespace, so what was before
rails g componentis nowrails g view_component:component.
New features
- Add
SystemSpecHelpersfor use with RSpec. - Add support for including
Turbo::StreamsHelper. - Add template annotations for components with
def call. - Graduate
SlotableDefaultto be included by default. - Add
#current_templateaccessor andTemplate#pathfor diagnostic usage. - Reduce string allocations during compilation.
- Add
around_renderlifecyle method for wrapping component rendering in custom instrumentation, etc.
Bug fixes
- Fix bug where virtual path wasn't reset, breaking translations outside of components.
- Fix bug where
config.view_component.previews.enableddidn't function properly in production environments. - Fix bug in
SlotableDefaultwhere default couldn't be overridden when content was passed as a block. - Fix bug where request-aware helpers didn't work outside of the request context.
ViewComponentsSystemTestControllershouldn't be useable outside of test environment
Non-functional changes
- Remove unnecessary usage of
ruby2_keywords. - Remove unnecessary
respond_tochecks. - Require MFA when publishing to RubyGems.
- Clean up project dependencies, relaxing versions of development gems.
- Add test case for absolute URL path helpers in mailers.
- Update documentation on performance to reflect more representative benchmark showing 2-3x speed increase over partials.
- Add documentation note about instrumentation negatively affecting performance.
- Remove unnecessary ENABLE_RELOADING test suite flag.
config.view_component.previews.default_layoutshould default to nil.- Add test coverage for uncovered code.
- Test against
turbo-railsv2andrspec-railsv7.
v4.0.0.rc5
-
Revert change setting
#format. In GitHub's codebase, the change led to hard-to-detect failures. For example, components rendered from controllers included layouts when they didn't before. In other cases, the responsecontent_typechanged, breaking downstream consumers. For cases where a specific content type is needed, use:respond_to do |f| f.html_fragment do render(MyComponent.new) end end
Joel Hawksley
v4.0.0.rc4
-
Fix issue where generators were not included in published gem.
Jean-Louis Giordano
v4.0.0.rc3
-
Fix bug where relative paths in
translatedidn't work in blocks passed to ViewComponents.Joel Hawksley
-
Reformat the docs avatars section to arrange them in a grid.
Josh Cohen
-
Add SerpApi to "Who uses ViewComponent" list.
Andy from SerpApi