DEV Community

Rails Designer
Rails Designer

Posted on • Originally published at railsdesigner.com

1 1 1 1

Spacer Components introduced in ViewComponent 3.20

This article was originally published on Rails Designer


Version 3.20 of ViewComponent introduced spacer_component.

It's a new attribute that can be added to a collection to add another component between each item of a collection. It works like this:

<%= render(ProductComponent.with_collection(@products, spacer_component: SpacerComponent.new)) %>
Enter fullscreen mode Exit fullscreen mode

This will then render SpacerComponent's between each ProductComponent. Pretty cool.

If you think, you've seen this feature before. You could be right. It was inspired by Rails' collection partial rendering.

Top comments (0)

Cloudinary image

Zoom pan, gen fill, restore, overlay, upscale, crop, resize...

Chain advanced transformations through a set of image and video APIs while optimizing assets by 90%.

Explore

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay