I want to render table in custom print format.
Template is taken from example (https://frappe.github.io/erpnext/user/manual/en/customize-erpnext/print-format.html)
<table class="table table-bordered">
<tbody>
<tr>
<th>Sr</th>
<th>Item Name</th>
<th>Description</th>
<th class="text-right">Qty</th>
<th class="text-right">Rate</th>
<th class="text-right">Amount</th>
</tr>
{%- for row in doc.items -%}
<tr>
<td style="width: 3%;">{{ row.idx }}</td>
<td style="width: 20%;">
{{ row.item</em>name }}
{% if row.item<em>code != row.item</em>name -%}
<br>Item Code: {{ row.item<em>code}}
{%- endif %}
</td>
<td style="width: 37%;">
<div style="border: 0px;">{{ row.description }}</div></td>
<td style="width: 10%; text-align: right;">{{ row.qty }} {{ row.uom or row.stock</em>uom }}</td>
<td style="width: 15%; text-align: right;">{{
row.get<em>formatted("rate", doc) }}</td>
<td style="width: 15%; text-align: right;">{{
row.get</em>formatted("amount", doc) }}</td>
</tr>
{%- endfor -%}
</tbody>
</table>
After saving custom HTML template is modified to:
{%- for row in doc.items -%}
{%- endfor -%}
<table class="table table-bordered">
<tbody>
<tr>
<th>Sr</th>
<th>Item Name</th>
<th>Description</th>
<th class="text-right">Qty</th>
<th class="text-right">Rate</th>
<th class="text-right">Amount</th>
</tr><tr>
<td style="width: 3%;">{{ row.idx }}</td>
<td style="width: 20%;">
{{ row.itemname }}
{% if row.item<em>code != row.item</em>name -%}
<br>Item Code: {{ row.item<em>code}}
{%- endif %}
</em></td>
<td style="width: 37%;">
<div style="border: 0px;">{{ row.description }}</div></td>
<td style="width: 10%; text-align: right;">{{ row.qty }} {{ row.uom or row.stockuom }}</td>
<td style="width: 15%; text-align: right;">{{
row.get<em>formatted("rate", doc) }}</em></td>
<td style="width: 15%; text-align: right;">{{
row.getformatted("amount", doc) }}</td>
</tr></tbody>
Loop position now is before table. From debugging - it is made by java script. Any ideas how to fix this or write needed template?