This project is archived and is in readonly mode.
Parameterized partials
-
Steve St. Martin
- Assigned user set to Ryan Bigg
Not sure I 100% understand the usecase here why if readability was more important than dry how adding :context makes it anymore readable.
I would use the following, it gives you the separation you require, no added functionality, and reads cleanly showing its intent. the only sacrifice is the partials are not all contained under views/products. However i would argue that if the partials are so heavily different they cannot be shared, they are likely tied to the section they are contained within to begin with.
# views/shopping_cart/show.html.erb -> /views/shopping_cart/_product.html.erb <%= render :partial => 'product', :collection => @cart.products %> # views/categories/show.html.erb -> /views/categories/_product.html.erb <%= render :partial => 'product', :collection => @category.products %> # views/products/show.html.erb -> /views/products/_product.html.erb <%= render :partial => 'product', :collection => @products %>suggest marking as invalid