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

Concat

Concat (concatenates) tag allows to combine number of arrays. The final array will contain all the elements of the original arrays. It is important to note that the duplicate entries will not be removed from the combined final array unless you use the uniq filter.

{% assign fixed_assets = "buildings,land,computer equipment" |split:"," %}
{% assign intangible_assets = "goodwill,patents,trademarks" |split:"," %}

{% assign assets = fixed_assets |concat:intangible_assets %}

{{ assets |join:", " }}
Output (arrays)
buildings, land, computer equipment, goodwill, patents, trademarks

It can be also applied to collections, as shown in the example below.

{% fori item in custom.items1 %}
  {% input item.name %}
  {% input item.category %}
{% endfori %}

{% fori item in custom.items2 %}
  {% input item.name %}
  {% input item.value %}
{% endfori %}


{% assign items = custom.items1 | concat:custom.items2 %}

{% for item in items %}
  {{ item.name }}
  {{ item.category }}
  {{ item.value }}
{% endfor %}
Output (collections)

Split

Will split up a string into an array with the given argument.

{% assign used_acc_numbers = "610000;610015;610023;610045" | split:";" %}

{% for acc in used_acc_numbers %}
  {{ acc }}
{% endfor %}
Output
610000

610015

610023

610045

First

Returns the first item of an array.

{% assign used_acc_numbers = "610000;610015;610023;610045" | split:";" %}

{{ used_acc_numbers | first }}
Output
610000

Last

Outputs the last item of an array.

{% assign used_acc_numbers = "610000;610015;610023;610045" | split:";" %}

{{ used_acc_numbers | last }}
Output
610045

Array indices

Alternatively to using the "first" and "last" filters we can use indices.
What's more is that by using indices we are not limited to the first or last item of the array, we can chooses whichever element we want.

When we want to return a particular value from an array based on its “place” in the array we use brackets [] to do so. We attach brackets to the name of the array. The contents of the brackets will be the place (= index) of the value which we wish to return.

❗️

0 not 1

Arrays start from 0, not 1. So, if we want to return the third value of an array we will have to input [2]

{% assign my_array = "place_0|place_1|place_2" | split:"|" %}
{{ my_array[2] }}

We build our array with the elements "place_0", "place_1" and "place_2". When we want to return "place_2" we will have to input my_array[2]. Keeping in mind that we would indicate this as the third element in human language but the element with index 2 in array language.

Output
place_2

Join

Will join each element of an array with the argument.

{% assign used_acc_numbers = "610000;610015;610023;610045" | split:";" %}

{{ used_acc_numbers | join:" & " }}
Output
610000 & 610015 & 610023 & 610045

Sort

Will sort an array.

{% assign active_directors = "Tim;Joris;Sven" | split:";" %}

{{ active_directors | sort | join:" "  }}
Output
Joris Sven Tim

Size

Will return the numbers of characters of a given string or give the number of items in an array. This filter can also be used as a [linkto methods]method[endlinkto].

{% assign active_directors = "Tim;Joris;Sven" | split:";" %}

{{ active_directors | size  }} or {{ active_directors.size  }}
Output
3 or 3

Uniq

Will return unique elements of an array.

{% assign my_accounts = "610000,610023,610045,610000" | split:"," %}

{{ my_accounts | uniq | join:", " }}
Output
610000, 610023, 610045

Where

Will create an array including only the objects that meet the established condition.

{% assign genders = "Female|Male|Other" %}
{% fori people in custom.people %}
  |{% input people.name %}
    |{% input people.gender | as:select | options:genders %}
{% endfori %}

{% assign women = custom.people | where:'gender','Female' %}

{% for woman in women %}
  {% if forloop.last %}{% assign names = names | append:woman.name | append:"." %}
  {% else %}
  {% assign names = names | append:woman.name | append:", " %}
  {% endif %}
{% endfor %}

Women: {{ names }}
Output

📘

Community Case

For more examples of usage, please, refer to our Community case post

Updated 3 months ago

Array


Suggested Edits are limited on API Reference Pages

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