Passing a block to a cell

10 views
Skip to first unread message

Mike Pence

unread,
Sep 16, 2014, 1:12:23 PM9/16/14
to cells-an...@googlegroups.com
hey guys,

I am looking to do this:

= render_cell :container, :display do
  = render_cell :contained, :display

...but the &block does not seem to get passed to the :display method. 

Mike Pence

unread,
Sep 16, 2014, 1:26:59 PM9/16/14
to cells-an...@googlegroups.com
...and I see from the source that passing a block lets you do some additional stuff with the cell instance, but is not the right way to do what I want to do.

Nick Sutterer

unread,
Sep 16, 2014, 6:09:59 PM9/16/14
to cells-an...@googlegroups.com
Hi Mike,

You can pass the content into the render_cell call and then use it in your view. BTW, you should change to view models, Cells 4.0 doesn't support render_cell anymore (README coming soon).

Is that a feature we could need in Cells 4.0?

= cell(:container).call do 
  = cell(:song).call

Nick

--
Sie erhalten diese Nachricht, weil Sie in Google Groups E-Mails von der Gruppe "Cells and Apotomo" abonniert haben.
Wenn Sie sich von dieser Gruppe abmelden und keine E-Mails mehr von dieser Gruppe erhalten möchten, senden Sie eine E-Mail an cells-and-apot...@googlegroups.com.
Weitere Optionen finden Sie unter https://groups.google.com/d/optout.

Mike Pence

unread,
Sep 16, 2014, 6:58:27 PM9/16/14
to cells-an...@googlegroups.com
So you would just call yield in the song container cell?

Nick Sutterer

unread,
Sep 16, 2014, 7:16:46 PM9/16/14
to cells-an...@googlegroups.com
No, yield won't work. It's all manual work. You pass the content block into the cell and handle it as a variable. The same way you deal with other options.

render_cell(:container, :show, content: html)

Then, in the show.haml view:

= html

It's clumsy. We can think about allowing this in Cells 4.0 (which doesn't use ActionView anymore, is a million times faster, and less code). 
360.gif
Reply all
Reply to author
Forward
0 new messages