Include

The include tag is used to make your code clean and comprehensible

Parts

The code of reconciliation templates is stored in a main part and in 11 optional parts. The main part is always loaded first, while the additional parts are only loaded when they are called. The parts can be accessed by using:

{% include 'parts/name_of_a_part' %}

This code will only be executed if one of the parts is named name_of_a_part:

Define a part name

Using parts is especially useful to store translations or to store blocks of code that are executed multiple times in your template. It makes the main part cleaner and easier to read.

Bear in mind that liquid is executed from top to bottom. This means that if you declare and initialise variables before including a part, you can call those variables within that part.

Shared Parts

❗️

Shared parts have to be activated upon request to be utilised.

A shared part can be used in multiple templates.

When there is a snippet of code that is repeated in several templates a shared part can be useful. This would allow you to modify the code in one place when needed, and it will impact all the templates that use it. This can help prevent having to fix a bug over multiple places for a repetitive item.

E.g. A common use of the shared part would be for general translations that get used repetitively. Hereby you can use a shared piece so if you have made a mis-spelling you will be able to edit the shared part and it will apply to all places this translation tag was applied using this shared part. Keep in mind that the shared part is not taken from outside the template like a result tag but the code is executed within the template at the exact place you have included it.

To create a shared part underneath the template section near the bottom you will find the sub-heading “Shared Parts”. Here you can add a “shared part”.

Define a recognizable name for the shared part

Let’s assume you have created a shared part with the following labeled general_translations with the following information in it;

{% t="trademarks_t" en:"Trademarks" da:"Varemærker" default:"Varemærker" %}

Create a blank template

On the top navigation bar you will see the option “Add Shared Part"

When choosing this option you will see a dropdown of all the shared parts that have previously been created in this environment.

Add the shared part you wish to use. E.g. general_translations shared part, you can do this by using the include shared tag. Remember the part will only be included from the point this text has been added.

Select "Add Shared Part"

In the main body you can include the following .

{% include "shared/general_translations" %}
{{ trademarks_t }}
Output
Output (in English) : Trademarks
Output (in Danish) : Varemærker
Output (in any other language): Varemærker