Include

With the include tag you can access code stored in parts

Parts

The code of reconciliation templates is stored in a main part and in 15 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 upon those variables within that part.

Shared Parts

❗️

Shared parts have to be activated in your firm 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. If you would have made a spelling mistake, you will be able to edit the shared part and it will apply to all templates this translation tag was used in with 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.

Once shared parts have been activated in your firm, you can add one by going to the "shared parts" subsection on the templates tab.

Add a new shared part

Let’s assume you have created a shared part 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 firm.

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

🚧

Updating shared parts

In Silverfin, updating a template will create a new version of it in your firm. The same goes for shared parts. Additionally, updating a shared part will also create a new version for every template this shared part has been added to. You will receive an error message if you want to save code changes done to a template if a shared part has been updated in the meantime.