Input Data Reference

Templates

Description

Templates are the core mechanism by which users can customise the generation of invoices or quotes. After processing all other input data and calculating subtotals and totals, the invoice generator passes all data to the user’s selected template for formatting. Templates control how this information is presented and acted upon, using powerful features of the Jinja template engine including loops and conditional statements.

Although line item data must follow a predetermined information schema, all other input data adheres to whatever schema is prescribed by the selected template. This provides users with the flexibility to incorporate any arbitrary information of their choosing when generating invoices and quotes.

Templates can opt to allow visual customisation via stylesheets by including the {{ css }} template tag. This allows users to create any number of different visual themes that are compatible with a single template, or with a set of conventions that one or more templates adhere to. If users do not want to make use of this functionality then they can simply omit the {{ css }} template tag and embed CSS code directly in templates.

For a full guide on writing templates, see the Writing templates page.

Data format

When using this interface: Use this data format:
Command-line interface HTML file
Python API str (string containing HTML code)
gRPC Microservice (coming soon)

Examples

You can find the default template that ships with the command-line interface for gen-invoice here: https://github.com/adamrehn/gen-invoice/blob/master/gen_invoice/defaults/default.html

The default template is designed to be as generic and flexible as possible, serving as a potential basis for other templates. The default template is also designed for visual customisation via stylesheets, including the default stylesheet that ships with the command-line interface for gen-invoice.