I have this layout and it has several “boxes” that have different content for every single view. The rest is the same for all of them.
This boxes are in my layout like = yield :box_1, = yield :box_2, etc. And in my views I fill them using:
- content_for :box_1 do
= render 'partials/box_1', :product => @product
- content_for :box_2 do
= render 'partials/box_2', :product => @product
,etc.
The problem is I’m writing these lines above in every single view, and it definitely don’t look DRY. What would be a better option for accomplish this?
I think a helper would be this first and easiest thing you can do.
And then you can put this helper into your layout.
Then the content should only be rendered if you have a product. But then you can also do the rendering directly there.