Guide
Tables
Build a PDF table from a list in your data, with fixed column widths, a header row on every page and running totals (Übertrag) at each page break.
On this page
Tables in Markdown
A normal Markdown table works. Put {{#each}} between the rows to repeat a
row for each item:
| Pos. | Leistung | Betrag |
| --- | --- | ---: |
{{#each rechnung.positionen}}
| {{ pos }} | {{ text }} | {{ betrag | money }} |
{{/each}}The | inside {{ betrag | money }} does not start a new column.
The table block
For longer tables, describe the table in the front matter. Brevier writes the HTML for you.
---
table:
items: rechnung.positionen
columns:
- field: pos
label: Pos.
width: 1fr
- field: text
label: Leistung
width: 6fr
- field: betrag
label: Betrag
width: 2fr
align: right
format: money
header:
repeat: true
zebra: true
---The table goes where the body has {{ table }}. Without that tag, it goes
at the end.
| Key | Meaning |
|---|---|
items |
The list in your data. One row per item. |
columns |
One entry per column. |
header.repeat |
Repeat the header row on every page. |
header.style |
A CSS class for the header row. |
zebra |
Shade every second row. |
keepRowTogether |
Never split one row across two pages. |
Each column has these keys:
| Key | Meaning |
|---|---|
field |
The field in each item. |
label |
The header text. Without it, Brevier uses the schema's title, then the field name. |
width |
A share like 2fr, or a percentage like 40%. |
align |
left, center or right. |
format |
A formatter, like money or date. |
Running totals (Übertrag)
A German invoice that runs over several pages shows the sum so far at each page break. This row is the Übertrag. Brevier adds it for you:
- at the bottom of a page, the sum of all rows above
- at the top of the next page, under the repeated header, the same sum again
In an HTML template, two attributes turn it on. data-brevier-uebertrag
goes on the table. data-brevier-carry marks the column to add up.
<table data-brevier-uebertrag="true">
<thead>
<tr><th>Pos.</th><th>Leistung</th><th data-brevier-carry="true">Betrag</th></tr>
</thead>
<tbody>
{{#each rechnung.positionen}}
<tr><td>{{ pos }}</td><td>{{ text }}</td><td>{{ betrag | money }}</td></tr>
{{/each}}
</tbody>
</table>Brevier renders the pages, finds the page breaks, inserts the two rows and renders again until the breaks stop moving. Each page keeps room for its own Übertrag rows. Brevier adds up with exact decimal numbers, so the cents always match.
The invoice on the templates page shows the result.