Reputation: 7810
For a site being built in Laravel, I have tables with a lot of variability in the tds.
As such, I was thinking that it might make sense to pull the td rendering logic out into a separate view partial.
However, the following doesn't feel right, especially if the tables has hundreds of rows and lots of columns:
@foreach ($tableRows as $tableRow)
@foreach ($tableCols as $tableCol)
@include('partials.td', ['tableRow' => 'tableRow', 'tableCol' => 'tableCol'])
@endforeach
@endforeach
What's the best way to handle a view partial that may have to be included literally hundreds of times for a page to render?
Thanks.
Upvotes: 1
Views: 626
Reputation: 739
In my opinion, the best way would be using Vue templates. create a Vue file in js/assets and put the template in there, passing variables of td as props Vue will take care of the high number of data rows and will re-use things if possible.
BUT
if you want to reduce the load on the client side, your current way is OK; it can be improved a little, but for hundreds of rows of data, that's enough.
I still suggest putting the burden on the client-side.
Upvotes: 2