Views or Partials ?

17 views
Skip to first unread message

John Lane

unread,
May 7, 2014, 7:26:59 AM5/7/14
to cells-an...@googlegroups.com
Hi Nick,

You say

we don’t distinguish between view and partial – there’s no need for making thing more complex. Everything is a view… or a partial. We simply call it view.

In my app I want to render a collection and the natural way to do this is to use a partial:

<%= render :partial => :image, collection: @item.images %>

The view containing this is in my "item" widget (e.g. at "app/widgets/items/item/display.html.erb") but it looks for the partial in "app/widgets/items/image/_image.html.erb"

I would prefer it if it looked in "app/widgets/items/item/_image.html.erb"

If I change the above to

<%= render :view => :image, collection: @item.images %>

then it does look in the right place (the file name needs the underscore removed). However, as far as I can tell, rendering a view doesn't iterate over a collection.

Is there a reason why using render partial looks for the file in a different directory? Can it be coerced to look in the widget's directory?

Thanks,
John




Nick Sutterer

unread,
May 7, 2014, 8:52:13 AM5/7/14
to cells-an...@googlegroups.com
You can have partialsin Cells, they just don't start with an underscore and are called views. If you want your view with an underscore, say view: :_image.

Does that help?




--
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.

Nick Sutterer

unread,
May 7, 2014, 8:53:56 AM5/7/14
to cells-an...@googlegroups.com
The reason render :partial does weird stuff is because those calls are routed back to the original rails render stack which does tons of Rails magic that we don't want in Cells.

The lack of support for collections will be tackled this week, I find it annoying myself :)

Nick

John Lane

unread,
May 7, 2014, 11:12:46 AM5/7/14
to cells-an...@googlegroups.com
That sounds good. If you want somone to test a view with collections, let me know and I will checkout the latest from you...
Reply all
Reply to author
Forward
0 new messages