Trying to create a "view object" with yield self

Pry Flack
2013-06-06T17:48:46Z

Hi I''m having a problem creating a view widget inside my erb template.

Please see the following gist https://gist.github.com/5723324

Basically I''m trying to isolate a complex piece of html markup with
something like :

<%= Accordion.new(parent: "my-parent") do |accordion| %>
   accordion.element("elem1")
   accordion.element("elem2")
<% end %>

But yielding self does not return my object instance but the erb
template. It seems in rails there is a need to "capture" a given block
but I can''t figure out how to do this. I''m able to do
something similar
via a rails helper however I wanted to create an object to keep things
DRY. Any help much appreciated !

--
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 unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit