Getting started with Quaderno templates

What are templates?

Template is the word we use for how documents are structured in Quaderno. The good news is, you can customize them too!

Every receipt, invoice, estimate, and credit note is the result of filling that template with your information, making it look beautiful ✨

How do they work?

Quaderno templates are based on the Liquid templating engine created by the clever people over at Shopify.

If you have some HTML know-how and a rough idea of how coding works then you’re well up to the challenge of creating your own templates using the Quaderno system. If not, we have lots of examples to help you get started, including step-by-step instructions.

To learn about Liquid, we recommend checking out the basics page from Shopify, but here’s a quick rundown.

Templates use a combination of tagsobjects and filters to put your details (dynamic content) into the templates that structure your financial documents behind the scenes.

Tags

Tags are the brains of your document, denoted by curly braces and percentage signs: {% and %}. They let you make decisions in a document, like to create a temporary variable in your document, loop over a series of objects, or even whether to show a logo or not:

{% if account.logo_url != "" %}
    <img src="{{account.logo_url}}" width="150" />
{% endif %}

If the account object property logo_url is not equal (!=) to “” (meaning that it’s not empty), then you put an image in with the logo_url as the src (source). Boom! Your lovely logo in pride of place on your document.

Note that the tag itself does not show in the document at all – only the img between the tags will show, if that account.logo_url isn’t an empty string!

Objects

Objects (like the above account object) have attributes that you can access (like logo_url) to display information in your document. They basically tell Quaderno where to show content on a document, so, unlike tags, objects accessed in this manner are visible (unless hidden by surrounding tag conditions). They are always wrapped by double curly braces: {{ and }}, for instance you could show an item description on your invoice with {{ item.description }}.

Combining this with looping tags like {% for %} , you can show all your items in a table easily:

<table>
    {% for item in document.items %}
      <tr>
        <td>{{item.description}}</td>
        <td>{{item.quantity}}</td>
        <td class="right">{{item.unit_price}}</td>
        <td class="right">{{item.subtotal}}</td>
      </tr>
    {% endfor %}
</table>

Just like that, you’ve enumerated every item in the document (like a list of products on an invoice), displaying their description, quantity, unit price and subtotal!

Filters

Filters are useful tools to modify the output of object properties, making them a little better looking, easier to read or otherwise useful. They are used within an object and are separated from the object’s target (item.unit_price, for example), by a single pipe character: | (though usually you put a space in either side of the pipe for clarity as well).

For example, financial amounts are stored in the background as numbers of cents (or pence) so that no decimal rounding errors can impact your bottom line. That’s great, except when you want to display those numbers on your documents – people aren’t used to seeing €10 written as 1000 cents! With filters, you can handle this, like so:

<strong>{{ document.total | money }}</strong><br>

The money filter converts that document.total number in cents to a string (like 1000 -> “1000” as characters instead of numbers) based on the currency of the document.

You should check the official list of Liquid filters, they're really useful. You can also create your own, here are a few extra filters you can use with Quaderno templates:

Filter What it does Use example Output
country_name Converts the country code to a name, in the user’s language {{ contact.country | country_name }} España
money Converts the given number into a string based on the amount’s currency {{ document.total | money }} 250 USD
precision Format a number to 2 decimal places {{ item.quantity | precision }} 12.00

Quaderno-specific tips

Here are a couple of tips to help you get the most buttery-smooth results from your Quaderno templates:

  • Your canvas must be 800×1131 pixels in size
  • Your logo space must be 308×125 pixels in size
  • If you want to get the maximum quality when you print your invoice at 300dpi, your logo image file must be 945×380 pixels.
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us