Code structure

In this section you will learn some common practices to structure your code properly.

The structure of the code is essential for it's maintenance. The better, the more logical, it is structured, the easier other developers (e.g. reviewer) will be able to understand the code.

There are multiple ways to structure your code, but the Silverfin platform provides some useful features to help you:

  • You have multiple parts available to structure the code you are developing. Make smart use of these parts by taking following instructions into account:
    • Part 1 should always be used to add the translations.
    • When your code exists out of multiple calculations, consider to add them in an additional part.
  • Try to divide your template into sections (either based on code or on the design of the template) and add a comment line just before the start of each section. This way the code will be less overwhelming.
{% comment %}START OF HEADER SECTION{% endcomment %}
{% comment %}END OF HEADER SECTION{% endcomment %}

{% comment %}START OF BODY SECTION{% endcomment %} 
{% comment %}END OF BODY SECTION{% endcomment %}
  • Put all items from the following list together bundled on top of your template and use them throughout the rest of your code:
    • General assignments (e.g. tax percentages, benefit in kind forfaits,...)
    • Assignments of results from other templates
    • Text captures, configurable variables, account mapping, options and option values
{% assign start_date_year = period.year_start_date | date:'%Y' %}
{% assign forfait_pc_2019 = 72 %}
{% assign options_coefficient = "1|1,25|2|3,8" %}
  • If many templates are related to each other, consider the following approach:
    • Create an (additional) central template where the settings can be done which will apply for all linked templates The advantage is that choices and settings should only be done in 1 place.
    • When building many templates be aware of the dataflow to avoid circular references. For example if you want a result from template A to reference in template B, but template B want to reference something from template A. This won’t work at all. Solutions could be to have one “overview” template where all values are made, and use that template to reference from to all other templates. You can find more information on the community (
  • Do loops when it make sense + avoid letting the server make more calculations than needed.


Keep balance between loops & hard coded text (logic!). Remember to have focus on readability and easy maintenance in the future.