Technical Guide For Printing Templates

Welcome to the printing templates technical guide. This guide contains much more in depth information about printing templates and is meant to be an extension of the User Guide (which if you haven’t read yet, you really should).

This guide also contains technical details and resources for understanding how the system works under the hood.

Let’s get started!

This guide

This guide will differ slightly from the user guide in the following ways:

  • Variables dropdowns will be using the proper JSON format unlike the simplified version in the user guide
  • Variables dropdowns will be called “Hash” to stay consistent with the mustache docs and make reading this section easier

Mustache

One huge piece of the Paimnt printing template system is the mustache templating system. Mustache allows the developer to give data to the user and allows the user to then create a meaningful result out of it. In our case the data is a sale, an EFTPOS transaction, a customer, etc and the result is a print.

The docs for mustache can be found here. You will want to read this or have it handy before starting this section as we won’t be redefining terms from that document but will be referring to them.

The triple mustache

You may notice that the docs for mustache mention the triple mustache disables HTML escaping. In our version of mustache we have disabled this and therefore there is no real use for the triple mustache except for personal preference.

Errors

There are two ways an error can present itself.

The first way is by simply not rendering text. This happens when you reference a variable that doesn’t exist. Consider the following:

Hash
{}
Template
Customer name: {{customerName}}
OutputCustomer name:

The second way is by not printing at all. This is difficult to distinguish from other issues with printing such as a trigger not firing or the printer not accepting the print. The only known case for this issue so far is when mustache receives an invalid template such as the following:

Template
{{customerName}