Silverfin

The Silverfin Developer Hub

Welcome to the Silverfin developer hub. You'll find comprehensive guides and documentation to help you start working with Silverfin as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started

Control flow

The control flow tag creates conditions that decide whether blocks of code get executed.

If

The if statement checks whether a condition is true or false. If the condition is true, the code within the if statement gets executed.

📘

Let's assume that the variable profit contains the value 999,99.

{% if profit > 0 %}
  There's a profit this year.
{% endif %}
Output
There's a profit this year.

Else

The else statement is used in combination with the if statement. If the if statement is false, the else part will be executed.

📘

Let's assume that the variable profit contains the value -100,00.

{% if profit > 0 %}
  There's a profit this year.
{% else %}
  There's a loss this year.
{% endif %}
Output
There's a loss this year.

Elsif

The elsif statement is used in combination with the if statement. If the if statement is false, there will be checked if the elsif statement is true.

📘

Let's assume that the variable profit contains the value -100,00.

{% if profit > 0 %}
  There's a profit this year.
{% elsif profit < 0 %}
  There's a loss this year.
{% else %}
  There's nor a profit, nor a loss this year.
{% endif %}
Output
There's a loss this year.

Ifi

An ifi statement can be seen as an if statement that is always true in input view and depends on the condition in export view. The ifi statement can be combined with the elsif and/or else tags.

📘

In Silverfin there's an input view with fields that can be modified and an export view where only text is shown.

📘

Assume that the variable supply_change is 0.

{% ifi supply_change != 0 %}
  The supplies changed with {{ supply_change }}
{% endifi %}
Output (in input view)
The supplies changed with 0.
Output (in export view)

Unless

Code within unless tag will be executed unless the statement is true. It is the antagonist of the if statement. The unless statement can be combined with elsif and/or else tags.

📘

Let's assume that the variable profit contains the value 999,99.

{% unless profit > 0 %}
  There is a loss
{% endunless %}
Output
There's a profit

Case

The case statement is similar to a series of if statements on the same expression. In many occasions, you may want to compare the same variable with different variables.

📘

Let's assume that the fiscal_year variable is 2019.

{% case fiscal_year %}
{% when 2018 %}
  {% assign ratio = 0.23 %}
{% when 2019 %}
  {% assign ratio = 0.27 %}
{% else %}
  {% assign ratio = 0.19 %}
{% endcase %}


{{ ratio }}
Output
0.27

Updated 11 months ago

Control flow


The control flow tag creates conditions that decide whether blocks of code get executed.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.