This is my code for a table inside a snippet. This snippet is inside a div container. The issue is if the table has many rows, it becomes red and the content is spread to the next page improperly.
I’ve tried to apply a page break to each row but nothing is working. I’ve also tried to use handlebar functions like #each outside of the snippet on the main html but it does not work as well.
The pagination algorithm in Connect will not drill into a <div>, each <div> is considered an atomic element. Would it be possible for you to use an <article> or <section> instead of a <div>? Or perhaps remove the <div> and only keep its contents?
However, i discovered that this will not follow the margin limit set in the page setup. It just flows all the way to the end of the page. Is this intentional? Or is there a setting i need to adjust?
The inner #each needs to be around the <tr> instead of around the <tbody>.
I’m not sure what we are doing differently. Here is a test template (saved with 2023.2) based on the html you provided (with the #each moved, and without the page-break-after: always style on the <tr>). There is no <div> or <section>. After switching to preview mode the table is rendered with dummy data and it is split across pages.
Content overflowing the page margins can be caused by overflow. Page breaks are added based on element heights, but content can ignore element bounds and flow out, potentially across the margins. This is why it is usually a good idea to add the style overflow:hidden to containers.
But looking at the screenshot you posted, perhaps something else is going on.
The <thead> of the second table (with “Transaction Date”, “Pricing Date”, etc.) is already repeated on each page.
Having the first table (with “Policy Type”) repeated on each page as well would be more complicated. You could move that table to the <thead> of the second table, or you can try to script it with a post-pagination script. I would not recommend the latter, that would add a lot of complexity.
Initial POC (you will still need to fiddle with styles to make it look the way you want):