Using Rails 2.3.8. My site displays reviews. Depending on what context
the review is shown in the review''s heading and thumbnail change.
I''m trying to share a layout across several review partials. Each
partial would define a few snippets of HTML to be used in the layout.
Is this possible? I''ve tried several variations of the following:
#layout
.review[review]
.thumb
= yield :thumb
.details
%h4
= yield :heading
%div
Rest of layout.....
Using this renders index twice (index uses a layout too):
# index.html.haml
%h2 Product reviews
= image_tag(@product.url)
= render :layout => @reviews, :locals => { :product => @product } do
|section|
- if section == :thumb
thumb stuff
Using this causes content to be appended upon each iteration of the
content_for blocks:
# index.html.haml
- @reviews.each do |review|
- content_for :heading do
Heading stuff...
- content_for :thumb do
Thumb stuff...
= render :partial => "shared/review", :object => review,
:locals
=> { :product => @product }
I know I can make the blocks locals:
= render :partial => "review", :object => review, :locals =>
{ :product
=> @product, :heading => link_to(image_tag(@product.url), @product.name)
}
But this gets ugly as the HTML becomes more complex. Yes, I can use
helpers, but I''d prefer to keep the somewhat larger HTML snippets in
the
templates instead of doing things like:
content_tag :div, :class => dom_id(@user) do
content_tag :span, "xxxxx"
# more code...
end
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.