Let’s say you want to have an overview of all investment accounts starting with “24” and ending on “90”, to quickly see all your depreciation amounts.
You could’ve done this:
{% assign depreciation_acc = period.accounts | range:"240090,240190,241090,240290" %}
where you needed to know the accounts you wanted to add them, one by one in your range.
Of course using a wildcard would be much more needed here. And now this is possible, by using following code:
{% assign depreciation_acc = period.accounts | range:"24%90$" %}
{% stripnewlines %}
| {% t "Name acc." %}
| {% t "End value" %}
{% newline %}
|----30%----
|----10%----:
{% for acc in depreciation_acc %}
{% newline %}
| {{ acc.name }}
| {{ -1*acc.value | currency }} |
{% endfor %}
{% endstripnewlines %}
giving this output for example:
So in the part of the assing-code : range:"24%90$"
we use:
%
: that’s our wildcard; everything can be that percentage. What comes before and after will Silverfin look for.
$
: that’s to make the account unique. If we would have done just range:"24%90"
without the dollar-sign, the output would give accounts like 24159001 as well. I only want the accounts ending on “90” so adding the $-sign will solve just that.