I''d like to use the helper method with block technique, but I
can''t seem
to make it work the way I want with a list. I''m imagining something
like
this:
<% decorate_list_with_max(list, 5) do |item| %>
Here''s the item name: <%= item.name %>
<% end %>
decorate_list_with_max(list, max, &block) {
output = ""
index = 0;
list.each |item|
output << "Before item";
output << capture(item, &block)
output << "After item";
index = index + 1
break if index > max
end
}
I think you get the idea? My helper gets a list, iterates over it
passing to the block in the view on each iteration (and passing an
argument to the block), with full control of the logic of the iteration,
including stopping it in the middle, etc.
It seems like there ought to be a way to do this. But I''m not
succeeding
in making it work. Anyone done something like this before?
Oh, Rails 1.8.x, not 2 yet.
--
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---