It would be really great if there were an object to which one can ‘bind’ general methods and properties to (cfr. the ‘application’ object in Excel VBA).
That way, general functions that can be applied anywhere (such as ‘find the last occurence of a given substring in a string’) only have to be defined once and can be applied to an input that is not linked to either the period or the company object.
I find myself having to repeat some code over and over again (and - as a good friend-programmer once said - the ideal programmer is essentially a very lazy person who doesn’t like to repeat himself …
Could you give examples of codes you have to repeat? Because if we think it can be generic and has benefits for other template builders, feel free to ask.
The sequence mentioned below takes a (structured) string in the form of A, B, C and ‘reforms’ it to A, B en C. Not mission critical in any way, but really handy to make an output more readable and ‘human’. So the input parameter (str_VGD_Vennootschappen_Namen) is not bound to a company or a period object.
{% comment %}haal de namen van alle vennootschappen uit de parameters{% endcomment %}
{% assign str_VGD_Vennootschappen_Namen = period.reconciliations.Parameters.results.VGD_Vennootschappen_Namen | strip %}
{% assign arr_VGD_Vennootschappen_Namen = str_VGD_Vennootschappen_Namen | split: '|' %}
{% assign int_XthCommaToReplace = arr_VGD_Vennootschappen_Namen.size | minus: 1 %}
{% comment %}vervang de '|' door ', ' (behalve de laatste door ' en '{% endcomment %}
{% for vennootschap in arr_VGD_Vennootschappen_Namen %}
{% assign counter = counter | plus:1 %}
{% if counter == int_XthCommaToReplace %}
{% assign str_Vennootschappen_Correct = str_Vennootschappen_Correct | append: vennootschap | append: ' en ' %}
{% else %}
{% assign str_Vennootschappen_Correct = str_Vennootschappen_Correct | append: vennootschap | append: ', ' %}
{% endif %}
{% endfor %}
{% assign str_Vennootschappen_Correct_Length = str_Vennootschappen_Correct.size | minus: 2 %}
{% assign str_Vennootschappen_Correct = str_Vennootschappen_Correct | slice: 0, str_Vennootschappen_Correct_Length %}
{{str_Vennootschappen_Correct}}
You can capture that whole code, and take it into a result-tag. Or even better: the outcome of that code can be taken into a result-tag @Bart_Verhaeghe
That way you can use it anywhere else
Why don’t you generate all needed code in that one template with the handle “Parameters”? Think that’s why you made it, no, looking at the name of that handle?