I have a form that has a variable number of line items, each having the same inputs and icons and lots of other elements. I have a
_line_item.html.erb partial that gets used in a loop in the view to show existing line items.
This is all kind of ugly, and not at all DRY, so I was wondering - is there any way to leverage the HTML present in the erb partial for appending new line items, WITHOUT having to hit the controller first? Or, is there a better client-side way of handling appending reusable blocks of HTML?
Also, cloning is not an option since at some point the user could remove all their line items. I guess I could leave a hidden one in the DOM somewhere, rendered via the erb partial, but that also feels not great.