I’ve got two models,
Users, as part of a little chore-tracking CRUD app. When you go to the index route for either model, I display all the entries in pretty similar forms: a
<table> with a
<th> row and each database entry as a
As part of the app, when you view a single user (i.e.
/users/:id), you can see all the chores that this user needs to take care of. I display these chores using the exact same table as I do at
/chores, just with a filtered set of rows.
Here’s my problem: now I’ve got two different files (
chores.html) that have the exact same code, and I have to worry about keeping them in sync. I would love to pull this code out somewhere, and in both of these places do something like
@import chores-table and just pass in different lists.
I’m basically brand-new to Phoenix – maybe there’s a really obvious way to do this that I’m missing. Or maybe there are lots of ways! How do you make reusable components for your views?