How to edit templates - contracts, invoice documents and email

Introduction

This article is guideline to editing all types of templates. These can be for emails, contracts and invoices.
You can find them in Settings/Templates. Each type of template has its own section.

Whenever you open a template, there are two options to edit it - Editor and Code.

Using the editor to edit templates

In the editor, you can see a preview that's easier to read and handle. It works similarly to a regular text editor. 

Here are the functions of the editor:

  • Insert property - allows you to add some of the properties, that are available for the selected type of template.
    For a full list of all available properties, please check the following articles:
  • Format - select the type of text you want to use:
    • Paragraph
    • Quotation
    • Heading 1 to Heading 6
  • Font Type
  • Font Size
  • Font Colour
  • Background Colour
  • Bold
  • Italic
  • Underline
  • Strikethrough
  • Alignments
    • Align left
    • Align center
    • Align right
    • Justify
  • Insert unordered list
  • Insert ordered list
  • Indent
  • Insert hyperlink
  • Subscript
  • Superscript
  • More tools
    • Clean formatting - removes all formatting for the selected text.
    • Table Wizard - allows you to create a table with the details that you've specified in the menu:

      s1.PNG

How to edit the code of a template

If you click Code, you'll see what lies behind this preview - HTML code. Everything you do in the editor is translated into HTML. If you are familiar with HTML, you can do a lot with manual scripting. But for now, we are going to cover how to add properties directly in the code. Let's take a look at a default "Welcome" email template in code. 

 

2019-11-15_0047.png

Notice how in the Editor view, the properties are shown in square brackets [property] and yellow color. In the code, they look like this: {{ property }}.
There are many properties you can use. Although lot of them can be added through the editor's "Insert Property" in the editor, but not all are there.

You can find a list of available properties for the respective type of templates below:

Those lists are almost complete, with the major exception of this are custom properties.
The only way to insert a custom property is through code and we'll cover this below.

How to add custom properties to templates

Custom properties are applied to different sections of the site. For example members, companies, locations etc.
In order to reference a custom property in the template, you need to use its unique identifier:

s1.PNG

Depending on what the custom property applies to, you can reference them as follows:

  • Members - {{member.properties["Enter unique identifier"]}}
  • Companies - {{team.properties["Enter unique identifier"]}}
  • Invoices - {{properties["Enter unique identifier"]}}
  • Contracts - {{contract.properties["Enter unique identifier"]}}
  • Locations - {{location.properties["Enter unique identifier"]}}

Note: Member and companies properties when used on invoices are both replaced with customer.properties.

Example: The property from the screenshot has a unique identifier named Amount Credited.
In order to reference the property, you need to write {{properties["Amount Credited"]}} as it applies to invoices.

Note: The identifier has to be written identically as it's specified in the UI, properties are case-sensitive.

If you already know where to place it and you can get around the code by yourself, then you can do it directly. Another option is to go back to the editor and follow these steps:

  1. Insert a placeholder string of text, e.g PROPERTY HERE
  2. Switch back to code
  3. Find where the property you just inserted is and replace it

We advise that you clone your template using the Clone button and test it before editing the default template.

Note: Email templates cannot be cloned, so take care when editing those types of templates.

How to add if (conditional) statements to templates

If you'd like to make the content of your template vary based on a specific property you can write an if statement.
This can be done by using the property name as follows:

{% if propertyName === value %}
This text will appear of the propertyName equals the value you've specified.
{% else %}
This text will appear if the propertyName equals something else different from the selected value.
{% endif %}

The main thing to consider when writing your "if" is the type of the property for which the if is being written:

  • String - you need to use quotes, e.g. propertyName === "value".
  • Number - just enter the numerical value. You can also use <,>,>=,<=, operators as wel as "===".
  • Boolean - you need to use quotes and check if the property is equal to "yes", e.g. booleanPropertyName === "yes".

It's also important to note that sometimes numerical values are formatted strings. This means you'll need to remove the formatting in order to write if statements for them.
This can be done by using parseMoney.

Example:

{% if parseMoney(contract.total) > 2000 %}
The contract costs more than 2000/year.
{% endif %}

Note: In order to find out whether a property needs to be parsed, it's best to first test the property itself by genering an example template. If it's a formatted number, parse it - if not you can write the if statement directly.

How to revert changes

You can abandon the changes you've made and revert to the default template by using the Revert button.

revert.png

Was this article helpful?
1 out of 5 found this helpful
Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.