Open dreyks opened 8 years ago
In 4.1, this is implemented: https://github.com/apotonick/cells/blob/4d39f994e6dd288367e75d30cec2d30ac7e1aec6/test/public_test.rb#L70
Is that cool?
so Cell::Collection#join
is the public API? that's good then, waiting for that 4.1 to release. Thx
ok, how is this supposed to look like in an erb template?
<%= cell('item', collection: @item).join do |cell, index| %>
<% cell.(:show, first_call: index.zero?) %>
<% end.html_safe %>
Am I doing this right? Looks not particularly nice, especially because of the need of html_safe
The html_safe
shouldn't be necessary since that's done via cells-rails
automatically. Other than that, what API would you like to have?
Uhm, that gem does not exist yet, does it?
Other than that, would be nice if index was merged into options, passed to @cell_class#build
, though you may consider this being too much magic)
We actually thought of a "collection context object". We could totally do that, that's not really magic.
:+1:
Similar to rails providing
item_counter
variable forrender partial: 'blah', collection: items
, index could be passed as a parameter for cell method. This simplifies things for something (say javascripts) that has to be rendered only once for entire collectionCell::Collection#call
almost has it, just needs to pass that index further