I’ve done the easy parts, I’ve got nested front matter, depicting line items in an invoice:
fee:
- description: Monthly Hosting
cost: 50
quantity: 3
- description: Tech Support
cost: 75
quantity: 6
- description: Monthly Hosting
cost: 20
quantity: 6
I can output my table just fine:
<table>
<thead>
<tr>
<th>Description</th>
<th>Cost</th>
<th>Qty</th>
<th>Line Total</th>
</tr>
</thead>
<tbody>
{{ range .Params.fee }}
<tr>
<td>{{ .description }}</td>
<td>{{ .cost }}</td>
<td>{{ .quantity }}</td>
<td>{{ mul .cost .quantity }}</td>
</tr>
{{ end }}
</tbody>
</table>
Produces expected table:
<table>
<thead>
<tr>
<th>Description</th>
<th>Cost</th>
<th>Qty</th>
<th>Line Total</th>
</tr>
</thead>
<tbody>
<tr>
<td>Monthly Hosting</td>
<td>50</td>
<td>3</td>
<td>150</td>
</tr>
<tr>
<td>Tech Support</td>
<td>75</td>
<td>6</td>
<td>450</td>
</tr>
<tr>
<td>Monthly Hosting</td>
<td>20</td>
<td>6</td>
<td>120</td>
</tr>
</tbody>
</table>
Okay, I want to total the line totals. I’m not sure where to go from here.