5.3. Using Template Placeholders

A template is a file, usually HTML, that contains FreeMarker code. Fanurio replaces the FreeMarker code with appropriate values to generate a final invoice as an HTML page.

Suppose you create an invoice that has the number INV-23 and you want to export it as an HTML file that includes the invoice number in the title. The template that would do that looks as follows:

<html>
<head>
	<title>Invoice: ${invoice.number}</title>
</head>
<body>
	<h1>Invoice</h1>
	<p><strong>Number:</strong> ${invoice.number}</p>
	<p align="center">Thank you for your business!</p>
</body>
</html>

When the invoice is generated, Fanurio replaces ${invoice.number} in both places with the actual number of the invoice. Here's how the generated invoice (HTML code) looks like:

<html>
<head>
	<title>Invoice: INV-23</title>
</head>
<body>
	<h1>Invoice</h1>
	<p><strong>Number:</strong> INV-23</p>
	<p align="center">Thank you for your business!</p>
</body>
</html>

In the above template, invoice.number is a placeholder for an invoice number and ${invoice.number} is the value of that placeholder. Just like invoice.number, there are many other placeholders that supply values related to the invoice, your business and your client's business. The complete list of placeholders can be found here.