Render slots in order
#2006
-
Hello! module Table::Beta::Row
class Component < ApplicationComponent
renders_many :cells
renders_many :status_cells, Table::Beta::Cells::Status
end
end template <% cells.each do |cell| %>
<td class="Table__cell"><%= cell %></td>
<% end if cells? %>
<% status_cells.each do |status_cell| %>
<%= status_cell %>
<% end if status_cells? %> which I use like this <%= body.with_row(path: shipment_load_path(load.shipment, load)) do |row| %>
<%= row.with_cell { "Hello" } %>
<%= row.with_status_cell { "Pending" } %>
<%= row.with_cell { "Bye" } %>
<% end %> As you may have guessed since I have two different
Was wondering if there is a way to render the cells and status_cell in the order they were defined?
Thank you! |
Beta Was this translation helpful? Give feedback.
Answered by
Spone
Mar 23, 2024
Replies: 1 comment 2 replies
-
My advice would be to refactor your code to use polymorphic slots, so you'll have only one list of slots, some will be |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
Jesusz0r
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My advice would be to refactor your code to use polymorphic slots, so you'll have only one list of slots, some will be
Cell
s, othersStatusCell
s.